forked from sat5297/hacktober-coding
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodechef.cpp
More file actions
40 lines (40 loc) · 1003 Bytes
/
codechef.cpp
File metadata and controls
40 lines (40 loc) · 1003 Bytes
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
#include<bits/stdc++.h>
typedef long long int ll;
#define io ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fr(i,l,r) for(ll i=l;i<r;i++)
#define lop ll t;cin>>t;while(t--)
#define maxn 50001
#define k 31
using namespace std;
ll st[maxn][k] ;
int main(){
io;
lop{
ll n , z ; cin >> n >> z ;
ll mp[100001] = {0} ;
ll ans = 0 ;
bool b = false ;
fr(i,0,n){
ll a ; cin >> a ;
mp[a]++ ;
}
for(ll i = 10000 ; i >= 1 ; i--){
while(mp[i] != 0){
z -= i ;
mp[i]-- ;
ans++ ;
mp[i / 2]++ ;
if(z <= 0){
b = true ;
break ;
}
}
if( b == true){
break ;
}
}
if(b == true) cout << ans << "\n" ;
else cout << "Evacuate" << "\n" ;
}
return 0 ;
}