-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcf1767b.cpp
57 lines (50 loc) · 1.12 KB
/
cf1767b.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
50
51
52
53
54
55
56
57
// cf1767b
#include <cstdint>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdint>
std::uint64_t solve()
{
std::uint64_t tower_count;
std::cin >> tower_count;
// first tower
std::uint64_t solution_tower_block_count;
std::cin >> solution_tower_block_count;
tower_count--;
// remaining towers
std::vector<std::uint64_t> tower_vector;
while (tower_count--)
{
std::uint64_t tmp;
std::cin >> tmp;
tower_vector.push_back(tmp);
}
// solve
std::sort(tower_vector.begin(), tower_vector.end());
for (std::uint64_t i : tower_vector)
{
if (i > solution_tower_block_count)
{
int tmp = solution_tower_block_count + i;
if (tmp % 2 == 0)
{
solution_tower_block_count = tmp / 2;
}
else
{
solution_tower_block_count = (tmp / 2) + 1;
}
}
}
return solution_tower_block_count;
}
int main()
{
std::uint64_t t;
std::cin >> t;
while (t--)
{
std::cout << solve() << "\n";
}
}