View Code of Problem 3686

#include<iostream>

using namespace std;

int a[1000000],b[1000000]={0};

int main(){
    int t;
    cin>>t;
    while(t--){
        int n,x;
        cin>>n>>x;
        for (int i = 0; i < n; i++)
        {
            cin>>a[i];
            b[i]++;
        }
        int flag=0;
        for ( i = 0; i < n; i++)
        {
            if(b[x-a[i]]== 1) {
            	flag=1;
            	break;
            }
           
        }
        if(flag) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;  
    }
    return 0;
}
/*
Main.cc: In function 'int main()':
Main.cc:19:15: error: 'i' was not declared in this scope
         for ( i = 0; i < n; i++)
               ^
*/

Double click to view unformatted code.


Back to problem 3686