6920 | 2023-12-19 18:45:30 | 111 | Pontos átlag 2 | cpp17 | Accepted 100/100 | 78ms | 7696 KiB |
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define pii pair<int, int>
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifdef CB
freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
#endif
int N, K;
cin >> N >> K;
vector<int> v(N);
for (int i = 0; i < N; i++) {
cin >> v[i];
}
int l = 0, h = 1e9;
while (l < h) {
int m = (l + h) / 2;
int SL = 0, SH = 0;
for (int i = 0; i < N; i++) {
SL += max(v[i] - m, 1ll);
SH += v[i] + m;
}
if (SL <= N * K && SH >= N * K) {
h = m;
}
else {
l = m + 1;
}
}
cout << l << '\n';
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1832 KiB | ||||
2 | Accepted | 3ms | 2024 KiB | ||||
subtask2 | 10/10 | ||||||
3 | Accepted | 3ms | 2240 KiB | ||||
4 | Accepted | 3ms | 2604 KiB | ||||
5 | Accepted | 3ms | 2968 KiB | ||||
6 | Accepted | 3ms | 3036 KiB | ||||
7 | Accepted | 3ms | 3044 KiB | ||||
8 | Accepted | 3ms | 3060 KiB | ||||
subtask3 | 20/20 | ||||||
9 | Accepted | 64ms | 5928 KiB | ||||
10 | Accepted | 64ms | 6056 KiB | ||||
11 | Accepted | 63ms | 6104 KiB | ||||
12 | Accepted | 63ms | 6212 KiB | ||||
13 | Accepted | 64ms | 6608 KiB | ||||
14 | Accepted | 64ms | 6432 KiB | ||||
15 | Accepted | 64ms | 6616 KiB | ||||
16 | Accepted | 64ms | 6612 KiB | ||||
17 | Accepted | 3ms | 3856 KiB | ||||
subtask4 | 24/24 | ||||||
18 | Accepted | 3ms | 4080 KiB | ||||
19 | Accepted | 3ms | 4092 KiB | ||||
20 | Accepted | 3ms | 4180 KiB | ||||
21 | Accepted | 3ms | 4172 KiB | ||||
22 | Accepted | 3ms | 4168 KiB | ||||
23 | Accepted | 3ms | 4276 KiB | ||||
24 | Accepted | 3ms | 4364 KiB | ||||
25 | Accepted | 3ms | 4356 KiB | ||||
26 | Accepted | 3ms | 4452 KiB | ||||
27 | Accepted | 3ms | 4484 KiB | ||||
28 | Accepted | 3ms | 4560 KiB | ||||
subtask5 | 46/46 | ||||||
29 | Accepted | 64ms | 7540 KiB | ||||
30 | Accepted | 68ms | 7496 KiB | ||||
31 | Accepted | 41ms | 6276 KiB | ||||
32 | Accepted | 61ms | 6928 KiB | ||||
33 | Accepted | 75ms | 7636 KiB | ||||
34 | Accepted | 75ms | 7696 KiB | ||||
35 | Accepted | 78ms | 7636 KiB | ||||
36 | Accepted | 78ms | 7632 KiB | ||||
37 | Accepted | 76ms | 7512 KiB | ||||
38 | Accepted | 75ms | 7564 KiB | ||||
39 | Accepted | 28ms | 5432 KiB | ||||
40 | Accepted | 4ms | 4720 KiB | ||||
41 | Accepted | 3ms | 4824 KiB |