12078 | 2024-11-30 12:17:14 | Dávid | Pontos átlag 2 | cpp17 | Wrong answer 0/100 | 114ms | 3536 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool f(ll x, ll k, vector<ll> arak) {
ll cel = arak.size() * k;
for(int i = 0; i < arak.size(); i++) {
cel -= arak[i];
}
for(int i = 0; i < arak.size(); i++) {
if(cel > 0) cel -= min(cel, x);
else if(cel < 0) cel += min(abs(cel), min(arak[i] - 1, x));
}
return cel == 0;
}
int main() {
ll n, k;
cin >> n >> k;
vector<ll> arak(n);
for(int i = 0; i < n; i++) {
cin >> arak[i];
}
ll l = 0, r = 1e10;
while(l < r - 1) {
ll kozep = (l + r) / 2;
if(f(kozep, k, arak)) {
r = kozep;
} else {
l = kozep;
}
}
cout << r << endl;
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 1ms | 320 KiB | ||||
2 | Accepted | 1ms | 320 KiB | ||||
subtask2 | 0/10 | ||||||
3 | Accepted | 1ms | 320 KiB | ||||
4 | Accepted | 1ms | 320 KiB | ||||
5 | Accepted | 1ms | 320 KiB | ||||
6 | Accepted | 1ms | 320 KiB | ||||
7 | Wrong answer | 1ms | 320 KiB | ||||
8 | Accepted | 1ms | 320 KiB | ||||
subtask3 | 0/20 | ||||||
9 | Accepted | 54ms | 3516 KiB | ||||
10 | Accepted | 56ms | 3520 KiB | ||||
11 | Wrong answer | 52ms | 3404 KiB | ||||
12 | Accepted | 52ms | 3384 KiB | ||||
13 | Accepted | 54ms | 3384 KiB | ||||
14 | Accepted | 54ms | 3528 KiB | ||||
15 | Accepted | 57ms | 3388 KiB | ||||
16 | Accepted | 61ms | 3380 KiB | ||||
17 | Accepted | 1ms | 320 KiB | ||||
subtask4 | 0/24 | ||||||
18 | Accepted | 2ms | 324 KiB | ||||
19 | Accepted | 1ms | 320 KiB | ||||
20 | Accepted | 1ms | 320 KiB | ||||
21 | Accepted | 1ms | 500 KiB | ||||
22 | Accepted | 1ms | 508 KiB | ||||
23 | Accepted | 1ms | 320 KiB | ||||
24 | Accepted | 1ms | 320 KiB | ||||
25 | Wrong answer | 1ms | 508 KiB | ||||
26 | Accepted | 1ms | 320 KiB | ||||
27 | Accepted | 1ms | 320 KiB | ||||
28 | Accepted | 1ms | 320 KiB | ||||
subtask5 | 0/46 | ||||||
29 | Accepted | 57ms | 3536 KiB | ||||
30 | Accepted | 78ms | 3520 KiB | ||||
31 | Accepted | 54ms | 2040 KiB | ||||
32 | Accepted | 75ms | 2988 KiB | ||||
33 | Accepted | 100ms | 3504 KiB | ||||
34 | Accepted | 108ms | 3384 KiB | ||||
35 | Wrong answer | 108ms | 3504 KiB | ||||
36 | Accepted | 114ms | 3512 KiB | ||||
37 | Accepted | 114ms | 3384 KiB | ||||
38 | Accepted | 98ms | 3384 KiB | ||||
39 | Accepted | 39ms | 1480 KiB | ||||
40 | Accepted | 3ms | 320 KiB | ||||
41 | Accepted | 1ms | 508 KiB |