11633 | 2024-11-02 10:11:23 | MagyarKendeSZLG | Pontos átlag 2 | cpp17 | Accepted 100/100 | 35ms | 2036 KiB |
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
#define int long long
int32_t main() {
cin.tie(0), ios::sync_with_stdio(0);
int N, K;
cin >> N >> K;
vector<int> p(N);
for (int& x : p) cin >> x;
int goal = N * K;
int avg = accumulate(p.begin(), p.end(), 0LL);
auto f = [&](int c) -> bool {
if (avg == goal) { return 1; }
if (avg < goal) { return avg + N * c >= goal; }
int d = 0;
for (int x : p) { d += min(x - 1, c); }
return avg - d <= goal;
};
int l = -1, r = 2e9;
while (r - l > 1) {
int m = (r + l) / 2;
if (f(m)) {
r = m;
} else {
l = m;
}
}
cout << r << "\n";
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 1ms | 320 KiB | ||||
2 | Accepted | 1ms | 320 KiB | ||||
subtask2 | 10/10 | ||||||
3 | Accepted | 1ms | 320 KiB | ||||
4 | Accepted | 1ms | 320 KiB | ||||
5 | Accepted | 1ms | 320 KiB | ||||
6 | Accepted | 1ms | 320 KiB | ||||
7 | Accepted | 1ms | 320 KiB | ||||
8 | Accepted | 1ms | 320 KiB | ||||
subtask3 | 20/20 | ||||||
9 | Accepted | 14ms | 1980 KiB | ||||
10 | Accepted | 20ms | 1848 KiB | ||||
11 | Accepted | 14ms | 1848 KiB | ||||
12 | Accepted | 20ms | 1848 KiB | ||||
13 | Accepted | 14ms | 1860 KiB | ||||
14 | Accepted | 21ms | 2028 KiB | ||||
15 | Accepted | 20ms | 1848 KiB | ||||
16 | Accepted | 20ms | 2036 KiB | ||||
17 | Accepted | 1ms | 320 KiB | ||||
subtask4 | 24/24 | ||||||
18 | Accepted | 1ms | 320 KiB | ||||
19 | Accepted | 1ms | 320 KiB | ||||
20 | Accepted | 1ms | 320 KiB | ||||
21 | Accepted | 1ms | 320 KiB | ||||
22 | Accepted | 1ms | 320 KiB | ||||
23 | Accepted | 1ms | 320 KiB | ||||
24 | Accepted | 1ms | 320 KiB | ||||
25 | Accepted | 1ms | 388 KiB | ||||
26 | Accepted | 1ms | 508 KiB | ||||
27 | Accepted | 1ms | 320 KiB | ||||
28 | Accepted | 1ms | 552 KiB | ||||
subtask5 | 46/46 | ||||||
29 | Accepted | 23ms | 1828 KiB | ||||
30 | Accepted | 28ms | 1848 KiB | ||||
31 | Accepted | 18ms | 1244 KiB | ||||
32 | Accepted | 20ms | 1912 KiB | ||||
33 | Accepted | 32ms | 1848 KiB | ||||
34 | Accepted | 32ms | 1848 KiB | ||||
35 | Accepted | 28ms | 1848 KiB | ||||
36 | Accepted | 35ms | 1848 KiB | ||||
37 | Accepted | 35ms | 1864 KiB | ||||
38 | Accepted | 26ms | 1848 KiB | ||||
39 | Accepted | 13ms | 824 KiB | ||||
40 | Accepted | 1ms | 320 KiB | ||||
41 | Accepted | 1ms | 508 KiB |