Submission #50327370
Source Code Expand
/** _ _ __ _ _ _ _ _ _ |a ||t ||o d | |o | | __ _| | _ | __| _ | | __ |/_ | __ /__\ / _\| **/ #include <bits/stdc++.h> using namespace std; typedef long long ll; int main () { ios_base::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; int a[n]; map <int, int> occ; int max_occ = 0; for (int i = 0; i < n; i++) { cin >> a[i]; max_occ = max(max_occ, ++occ[a[i]]); } vector <int> v; for (pair <int, int> p : occ) { if (p.second == max_occ) { v.push_back(p.first); } } ll answer = v.front() - v.back() + (ll) (n - max_occ) * k; int max_diff = 0; for (int i = 0; i + 1 < (int) v.size(); i++) { max_diff = max(max_diff, v[i + 1] - v[i]); } answer = max(answer, max_diff + (ll) (n - max_occ - 1) * k); cout << answer << "\n"; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Shuffle and mod K |
User | atodo |
Language | C++ 20 (gcc 12.2) |
Score | 500 |
Code Size | 945 Byte |
Status | AC |
Exec Time | 141 ms |
Memory | 13628 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 500 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example_00.txt, example_01.txt |
All | example_00.txt, example_01.txt, test_00.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
example_00.txt | AC | 1 ms | 3412 KiB |
example_01.txt | AC | 1 ms | 3520 KiB |
test_00.txt | AC | 1 ms | 3596 KiB |
test_01.txt | AC | 105 ms | 12308 KiB |
test_02.txt | AC | 62 ms | 9380 KiB |
test_03.txt | AC | 50 ms | 8872 KiB |
test_04.txt | AC | 12 ms | 4228 KiB |
test_05.txt | AC | 12 ms | 4260 KiB |
test_06.txt | AC | 12 ms | 4084 KiB |
test_07.txt | AC | 12 ms | 4056 KiB |
test_08.txt | AC | 12 ms | 4292 KiB |
test_09.txt | AC | 141 ms | 13572 KiB |
test_10.txt | AC | 125 ms | 13628 KiB |
test_11.txt | AC | 141 ms | 13576 KiB |
test_12.txt | AC | 1 ms | 3388 KiB |
test_13.txt | AC | 1 ms | 3456 KiB |
test_14.txt | AC | 4 ms | 3792 KiB |
test_15.txt | AC | 22 ms | 6600 KiB |
test_16.txt | AC | 30 ms | 7212 KiB |
test_17.txt | AC | 129 ms | 13472 KiB |
test_18.txt | AC | 2 ms | 3544 KiB |
test_19.txt | AC | 7 ms | 3884 KiB |
test_20.txt | AC | 11 ms | 4216 KiB |
test_21.txt | AC | 4 ms | 3680 KiB |
test_22.txt | AC | 5 ms | 3668 KiB |
test_23.txt | AC | 5 ms | 3732 KiB |
test_24.txt | AC | 9 ms | 3992 KiB |
test_25.txt | AC | 13 ms | 4232 KiB |
test_26.txt | AC | 13 ms | 4380 KiB |
test_27.txt | AC | 12 ms | 4048 KiB |
test_28.txt | AC | 16 ms | 4092 KiB |
test_29.txt | AC | 15 ms | 4088 KiB |
test_30.txt | AC | 16 ms | 4264 KiB |
test_31.txt | AC | 17 ms | 4252 KiB |
test_32.txt | AC | 45 ms | 7868 KiB |
test_33.txt | AC | 14 ms | 5224 KiB |
test_34.txt | AC | 5 ms | 4276 KiB |
test_35.txt | AC | 49 ms | 8476 KiB |
test_36.txt | AC | 51 ms | 8936 KiB |
test_37.txt | AC | 58 ms | 8928 KiB |