View Code of Problem 3686

#include<bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin>>t;
    while (t--){
        int n,x;
        cin>>n>>x;
        int m[100010];
        for (int i = 0; i < n; ++i) {
            cin>>m[i];
        }
        int flag=0;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                if (m[i]+m[j]==x&&i!=j)
                    flag=1;
            }
        }
        if (flag==1)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }


    return 0;
}

Double click to view unformatted code.


Back to problem 3686