Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int t;
- cin>>t;
- while(t--){
- int m,s;
- cin>>m>>s;
- set <int> S;
- for (int i=0; i<m; i++){
- int x;
- cin>>x;
- S.insert(x);
- }
- int maximum;
- auto it=S.end(); it--;
- maximum=*it;
- int i=1;
- while (s>0){
- if (S.count(i)==0){
- s=s-i;
- S.insert(i);
- }
- i++;
- }
- if (S.size()<maximum || s!=0) cout<<"NO\n";
- if (S.size()>=maximum && s==0) cout<<"YES\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement