← Back to List

3273번: 두 수의 합 ↗

Solutions

C++14
341 B | 341 chars
#include <iostream>
using namespace std;
int count[2200000],ar[110000];
int N,K,cnt;
int main()
{
    cin>>N;
    for(int x=0; x<N; x++)
    {
        cin>>ar[x];
        count[ar[x]]++;
    }
    cin>>K;

    for(int x=0; x<N; x++)
    {
        if(ar[x]<K)
        {
            cnt += count[K-ar[x]];
        }
    }

    cout << cnt/2;
}