-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCodeforces1221A.cpp
49 lines (49 loc) · 1 KB
/
Codeforces1221A.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define ff first
#define ss second
int main()
{
int n,i,j,q,sum=0;
cin>>q;
while(q--)
{
cin>>n;
int temp;
sum=0;
map<int,int>x;
for(i=0;i<n;i++)
{
cin>>temp;
if(sum<=2048){
sum+=temp;
}
if(temp<=2048)
{
x[temp]++;
}
}
if(sum<2048)
{
cout<<"NO"<<endl;
continue;
}
else if(sum==2048 || x[2048]>=1 || x[1028]>=2 || x[512]>=4 || x[256]>=8)
{
cout<<"YES"<<endl;
continue;
}
for(auto it: x)
{
if(it.ff<2048 && it.ss>1)
{
int k=(x[it.ff]/2);
x[it.ff]-=k*2;
x[it.ff*2]+=k;
}
}
if(x[2048]>=1) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}