Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2d5d3aa

Browse files
Initial commit
1 parent 4a4d407 commit 2d5d3aa

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//author @Nishant
2+
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
int main(){
7+
int n, m;
8+
cin >> n >> m;
9+
vector<int> a(n), b(n);
10+
int low = 0;
11+
for (int i = 0; i < n; i++) {
12+
cin >> a[i];
13+
14+
if (a[i] < a[low]) {
15+
low = i;
16+
}
17+
}
18+
19+
int high = 0;
20+
21+
for (int i = 0; i < m; i++) {
22+
cin >> b[i];
23+
if (b[i] > b[high]) {
24+
high = i;
25+
}
26+
}
27+
28+
for (int i = 0; i < m; i++) {
29+
if (i == high) continue;
30+
cout << low << ' ' << i << endl;
31+
}
32+
33+
for (int i = 0; i < n; i++) {
34+
cout << i << ' ' << high << endl;
35+
}
36+
37+
return 0;
38+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//author @Nishant
2+
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
int main(){
7+
int t;
8+
cin >> t;
9+
while(t--){
10+
int n, z;
11+
cin >> n >> z;
12+
int temp;
13+
vector<int> a(10001, 0);
14+
for(int i = 0; i < n; i++){
15+
cin >> temp;
16+
a[temp]++;
17+
}
18+
int count = 0;
19+
for(int i = 10000; i > 0; i--){
20+
while(z>0 && a[i]){
21+
z -= i;
22+
a[i / 2]++;
23+
a[i]--;
24+
count++;
25+
}
26+
if(z <= 0)
27+
break;
28+
}
29+
if(z <= 0) cout << count << endl;
30+
else cout << "Evacuate" << endl;
31+
}
32+
return 0;
33+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /