-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP2035.cpp
45 lines (43 loc) · 1.16 KB
/
P2035.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
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
int n, t;
int priorities[10010] = {0};
int main() {
std::cin >> n >> t;
for (int i = 1; i <= n; i++) {
std::cin >> priorities[i];
}
while (t--) {
int max = -114514; int max_index = 0;
for (int i = 1; i <= n; i++) {
if (priorities[i] > max) {
max = priorities[i];
max_index = i;
}
}
std::cout << max_index << std::endl;
priorities[max_index] = 0;
if (max % (n-1) == 0) {
int t = max / (n-1);
for (int i = 1; i <= n; i++) {
if (i == max_index) continue;
priorities[i] += t;
}
} else {
for (int i = 1; i <= n; i++) {
if (i == max_index) continue;
priorities[i] += 1;
max -= 1;
if ((max % (n-1)) == 0) break;
}
int t = max / (n-1);
for (int i = 1; i <= n; i++) {
if (i == max_index) continue;
priorities[i] += t;
}
}
}
return 0;
}