69192023-12-19 18:42:22111Pontos átlag 2cpp17Wrong answer 0/10078ms8120 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 += v[i] - m;
			SH += v[i] + m;
		}
		if (SL <= N * K && SH >= N * K) {
			h = m;
		}
		else {
			l = m + 1;
		}
	}
	cout << l << '\n';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms1832 KiB
2Accepted3ms2024 KiB
subtask20/10
3Accepted3ms2240 KiB
4Wrong answer3ms2448 KiB
5Accepted3ms2672 KiB
6Accepted3ms2868 KiB
7Accepted3ms3108 KiB
8Accepted3ms3304 KiB
subtask30/20
9Accepted64ms6276 KiB
10Wrong answer64ms6552 KiB
11Accepted61ms6648 KiB
12Accepted63ms6496 KiB
13Accepted64ms6840 KiB
14Accepted64ms6772 KiB
15Wrong answer64ms7028 KiB
16Wrong answer64ms7240 KiB
17Accepted3ms4440 KiB
subtask40/24
18Wrong answer3ms4552 KiB
19Wrong answer3ms4624 KiB
20Wrong answer3ms4592 KiB
21Wrong answer3ms4596 KiB
22Wrong answer3ms4412 KiB
23Accepted3ms4496 KiB
24Accepted3ms4496 KiB
25Accepted3ms4516 KiB
26Wrong answer3ms4472 KiB
27Wrong answer3ms4596 KiB
28Accepted3ms4624 KiB
subtask50/46
29Wrong answer64ms7844 KiB
30Wrong answer70ms7856 KiB
31Wrong answer41ms6892 KiB
32Accepted61ms7644 KiB
33Wrong answer74ms8048 KiB
34Wrong answer75ms7920 KiB
35Accepted78ms8120 KiB
36Wrong answer78ms8104 KiB
37Wrong answer78ms8028 KiB
38Accepted75ms7984 KiB
39Wrong answer28ms6060 KiB
40Wrong answer4ms5432 KiB
41Accepted3ms5212 KiB