-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1792A.cpp
More file actions
38 lines (33 loc) · 830 Bytes
/
Copy path1792A.cpp
File metadata and controls
38 lines (33 loc) · 830 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
// Created on 18-Feb-24
//done ac
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int health[n];
for (int i = 0; i < n; i++) {
cin >> health[i];
}
//sort, if 1 1 pair exist then 1st spell else kill each one with 2nd spell
sort(health, health + n);
int counter = 0;
int oneCounter = 0;
for (int i = 0; i < n; i++) {
if (health[i] == 1) {
oneCounter++;
} else {
counter += n - i;
break;
}
}
if (oneCounter % 2 == 0) counter += oneCounter / 2;
else counter += (oneCounter / 2) + 1;
cout << counter << endl;
}
return 0;
}