View Code of Problem 133

#include <iostream>
using namespace std;

int main(){
    int T,n,x;
    bool flag;
    cin>>T;
    while(T--){
        scanf("%d%d",&n,&x);
        int s[n];
        for(int k=0;k<n;k++)
            scanf("%d",&s[k]);
        flag = false;
        for(int k=0;k<n;k++)
            for(int l=k+1;l<n;l++)
                if(s[k]+s[l]==x){
                    flag = true;
                    break;
                }
        if(flag)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 133