Submission #48896079
Source Code Expand
Copy
#include <iostream>#include <vector>#include <algorithm>using namespace std;using ui = unsigned int;using ll = long long;int main(){ui n;cin >> n;if (n == 1){cout << 0 << endl;return 0;}vector<ll> a(n, 0);
#include <iostream> #include <vector> #include <algorithm> using namespace std; using ui = unsigned int; using ll = long long; int main() { ui n; cin >> n; if (n == 1) { cout << 0 << endl; return 0; } vector<ll> a(n, 0); ll sum = 0; for (auto &aa : a) { cin >> aa; sum += aa; } vector<ll> b(n, sum / n); for (ui i = 0; i < sum % n; i++) { b[n - 1 - i]++; } sort(a.begin(), a.end()); ll cnt = 0; for (ui i = 0; i < n; i++) { cnt += abs(a[i] - b[i]); } cout << cnt / 2 << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Approximate Equalization 2 |
User | michimani |
Language | C++ 20 (Clang 16.0.6) |
Score | 400 |
Code Size | 606 Byte |
Status | AC |
Exec Time | 61 ms |
Memory | 6408 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 03_handmade_00.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 1 ms | 3600 KB |
00_sample_01.txt | AC | 1 ms | 3448 KB |
00_sample_02.txt | AC | 1 ms | 3504 KB |
01_random_00.txt | AC | 1 ms | 3448 KB |
01_random_01.txt | AC | 1 ms | 3548 KB |
01_random_02.txt | AC | 60 ms | 6368 KB |
01_random_03.txt | AC | 60 ms | 6136 KB |
01_random_04.txt | AC | 60 ms | 6404 KB |
01_random_05.txt | AC | 61 ms | 6408 KB |
01_random_06.txt | AC | 61 ms | 6272 KB |
01_random_07.txt | AC | 60 ms | 6344 KB |
01_random_08.txt | AC | 60 ms | 6136 KB |
01_random_09.txt | AC | 60 ms | 6388 KB |
01_random_10.txt | AC | 61 ms | 6352 KB |
01_random_11.txt | AC | 60 ms | 6272 KB |
01_random_12.txt | AC | 61 ms | 6296 KB |
01_random_13.txt | AC | 59 ms | 6316 KB |
01_random_14.txt | AC | 60 ms | 6400 KB |
02_random2_00.txt | AC | 43 ms | 6360 KB |
02_random2_01.txt | AC | 44 ms | 6404 KB |
02_random2_02.txt | AC | 52 ms | 6360 KB |
02_random2_03.txt | AC | 36 ms | 6300 KB |
02_random2_04.txt | AC | 27 ms | 6356 KB |
02_random2_05.txt | AC | 42 ms | 6284 KB |
02_random2_06.txt | AC | 25 ms | 6228 KB |
02_random2_07.txt | AC | 30 ms | 6344 KB |
03_handmade_00.txt | AC | 54 ms | 6288 KB |
03_handmade_01.txt | AC | 1 ms | 3512 KB |
03_handmade_02.txt | AC | 19 ms | 6344 KB |
03_handmade_03.txt | AC | 1 ms | 3544 KB |