Skip to content

Commit 8332298

Browse files
committed
Create (CodeChef)Save_Konoha.cpp
1 parent 3816912 commit 8332298

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include<bits/stdc++.h>
2+
#include<iostream>
3+
using namespace std;
4+
5+
typedef long long int ll;
6+
7+
8+
9+
void subMain(){
10+
ll n, z, a, cnt = 0;
11+
cin >> n >> z;
12+
priority_queue<ll> q;
13+
for(ll i = 0; i < n; i++){
14+
cin >> a;
15+
q.push(a);
16+
}
17+
while(z > 0 && q.top() > 0)
18+
{
19+
ll ans = q.top();
20+
q.pop();
21+
z -= ans;
22+
q.push(ans/2);
23+
cnt++;
24+
}
25+
if(z > 0) {cout << "Evacuate" << "\n";}
26+
else {cout << cnt << "\n";}
27+
}
28+
29+
int32_t main(){
30+
31+
ios_base::sync_with_stdio(false);
32+
cin.tie(0); cout.tie(0);
33+
34+
35+
ll t;
36+
cin >> t;
37+
while(t--){
38+
subMain();
39+
}
40+
//subMain();
41+
return 0;
42+
}

0 commit comments

Comments
 (0)