Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma GCC optimize ("O3")
- #pragma GCC target ("sse4")
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef pair<int, int> pii;
- typedef pair<string,int> psi;
- typedef map<int,int> mii;
- typedef map<long long,long long> mll;
- typedef map<string,int> msi;
- typedef map<char,int> mci;
- typedef vector<int> vi;
- typedef vector<string> vs;
- typedef vector<char> vc;
- typedef vector<ll> vll;
- typedef vector<vector<int>> vvi;
- typedef vector<vector<string>> vvs;
- typedef vector<vector<ll>> vvll;
- #define FOR(i, a, b) for (auto i=a; i<=(b); i++)
- #define FORd(i,b,a) for (int i =b; i >= a; i--)
- #define sz(x) (int)(x).size()
- #define mp make_pair
- #define pb push_back
- #define f first
- #define s second
- #define ins insert
- const int MOD = 1000000007;
- //type functions here
- //using map
- bool check(mll &m,vi &v,int k,int offset)
- {
- int size=(v.size()-2);
- FOR(i,0,size)
- {
- ll temp=(v[i]+k);
- m[v[i]+offset]--;
- //cout<<" "<<temp<<" "<<v[i]<<" "<<endl;
- if(m[temp+offset]>0) return true;
- }
- return false;
- }
- int main() {
- int tc;
- cin>>tc;
- FOR(j,1,tc){
- vi v;
- int k=11,n=10;
- cin>>n>>k;
- FOR(i,1,n)
- {
- int temp;
- cin>>temp;
- v.pb(temp);
- }
- mll m;
- ll min=*min_element(v.begin(),v.end());
- sort(v.begin(),v.end());
- ll offset=0;
- if(min<0)
- offset=abs(min);
- for(auto x:v)
- m[x+offset]++;
- bool c=check(m,v,k,offset);
- if(c) cout<<"true"<<endl;
- else cout<<"false"<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement