# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
893243 | 2023-12-26T18:37:13 Z | vjudge1 | Gift (IZhO18_nicegift) | C++17 | 603 ms | 524288 KB |
// 以上帝的名义 // 候选硕士 #include <bits/stdc++.h> #ifdef local #include "algo/debug.h" #else #define dbg(x...) 0 #endif using namespace std ; using ll = long long ; #define int ll int32_t main() { cin.tie(0)->sync_with_stdio(false) ; ll n , k ; cin >> n >> k ; vector<ll> a(n) ; for (ll &i : a) cin >> i ; priority_queue<pair<ll,ll>> q ; for (int i = 0 ; i < n ; i++) { q.push({a[i], i}) ; } ll sum = accumulate(a.begin(), a.end(), 0ll) ; if (sum % k || (sum / k) < q.top().first) { cout << -1 << "\n" ; return 0 ; } vector<deque<ll>> res ; while (q.size() >= k) { deque<ll> cur ; ll mn = LLONG_MAX ; for (int i = 0 ; i < k ; i++) { auto [value, ind] = q.top() ; q.pop() ; cur.push_back(ind) ; mn = value ; } if (q.size() && sum % k == 0) mn = min(mn * 1ll, (sum / k) - q.top().first) ; assert(mn >= 0) ; sum -= k * mn ; for (ll& i : cur) { a[i] -= mn ; if (a[i]> 0) { q.push({a[i], i}) ; } i++ ; } cur.push_front(mn) ; res.push_back(cur) ; } if (q.size()) { cout << -1 ; return 0 ; } reverse(res.begin(), res.end()) ; cout << res.size() << "\n" ; for (auto i : res) { for (int j : i) cout << j << ' ' ; cout << "\n" ; } return 0 ; } // 希望白银
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | n=4 |
2 | Correct | 0 ms | 348 KB | n=3 |
3 | Correct | 0 ms | 348 KB | n=3 |
4 | Correct | 0 ms | 348 KB | n=4 |
5 | Correct | 0 ms | 348 KB | n=4 |
6 | Correct | 0 ms | 348 KB | n=2 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | n=4 |
2 | Correct | 0 ms | 348 KB | n=3 |
3 | Correct | 0 ms | 348 KB | n=3 |
4 | Correct | 0 ms | 348 KB | n=4 |
5 | Correct | 0 ms | 348 KB | n=4 |
6 | Correct | 0 ms | 348 KB | n=2 |
7 | Correct | 0 ms | 344 KB | n=5 |
8 | Correct | 1 ms | 344 KB | n=8 |
9 | Correct | 0 ms | 344 KB | n=14 |
10 | Correct | 0 ms | 348 KB | n=11 |
11 | Correct | 32 ms | 22352 KB | n=50000 |
12 | Correct | 27 ms | 18656 KB | n=50000 |
13 | Correct | 0 ms | 344 KB | n=10 |
14 | Correct | 1 ms | 604 KB | n=685 |
15 | Correct | 1 ms | 604 KB | n=623 |
16 | Correct | 1 ms | 604 KB | n=973 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | n=4 |
2 | Correct | 0 ms | 348 KB | n=3 |
3 | Correct | 0 ms | 348 KB | n=3 |
4 | Correct | 0 ms | 348 KB | n=4 |
5 | Correct | 0 ms | 348 KB | n=4 |
6 | Correct | 0 ms | 348 KB | n=2 |
7 | Correct | 0 ms | 344 KB | n=5 |
8 | Correct | 1 ms | 344 KB | n=8 |
9 | Correct | 0 ms | 344 KB | n=14 |
10 | Correct | 0 ms | 348 KB | n=11 |
11 | Correct | 32 ms | 22352 KB | n=50000 |
12 | Correct | 27 ms | 18656 KB | n=50000 |
13 | Correct | 0 ms | 344 KB | n=10 |
14 | Correct | 1 ms | 604 KB | n=685 |
15 | Correct | 1 ms | 604 KB | n=623 |
16 | Correct | 1 ms | 604 KB | n=973 |
17 | Correct | 1 ms | 604 KB | n=989 |
18 | Correct | 0 ms | 348 KB | n=563 |
19 | Correct | 1 ms | 348 KB | n=592 |
20 | Correct | 1 ms | 348 KB | n=938 |
21 | Correct | 1 ms | 348 KB | n=747 |
22 | Correct | 1 ms | 348 KB | n=991 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 603 ms | 375848 KB | n=1000000 |
2 | Correct | 308 ms | 180164 KB | n=666666 |
3 | Correct | 157 ms | 73140 KB | n=400000 |
4 | Correct | 100 ms | 42680 KB | n=285714 |
5 | Correct | 5 ms | 1496 KB | n=20000 |
6 | Correct | 57 ms | 20872 KB | n=181818 |
7 | Correct | 3 ms | 984 KB | n=10000 |
8 | Correct | 2 ms | 848 KB | n=6666 |
9 | Correct | 1 ms | 600 KB | n=4000 |
10 | Correct | 3 ms | 604 KB | n=2857 |
11 | Correct | 1 ms | 344 KB | n=2000 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | n=4 |
2 | Correct | 0 ms | 348 KB | n=3 |
3 | Correct | 0 ms | 348 KB | n=3 |
4 | Correct | 0 ms | 348 KB | n=4 |
5 | Correct | 0 ms | 348 KB | n=4 |
6 | Correct | 0 ms | 348 KB | n=2 |
7 | Correct | 0 ms | 344 KB | n=5 |
8 | Correct | 1 ms | 344 KB | n=8 |
9 | Correct | 0 ms | 344 KB | n=14 |
10 | Correct | 0 ms | 348 KB | n=11 |
11 | Correct | 32 ms | 22352 KB | n=50000 |
12 | Correct | 27 ms | 18656 KB | n=50000 |
13 | Correct | 0 ms | 344 KB | n=10 |
14 | Correct | 1 ms | 604 KB | n=685 |
15 | Correct | 1 ms | 604 KB | n=623 |
16 | Correct | 1 ms | 604 KB | n=973 |
17 | Correct | 1 ms | 604 KB | n=989 |
18 | Correct | 0 ms | 348 KB | n=563 |
19 | Correct | 1 ms | 348 KB | n=592 |
20 | Correct | 1 ms | 348 KB | n=938 |
21 | Correct | 1 ms | 348 KB | n=747 |
22 | Correct | 1 ms | 348 KB | n=991 |
23 | Correct | 603 ms | 375848 KB | n=1000000 |
24 | Correct | 308 ms | 180164 KB | n=666666 |
25 | Correct | 157 ms | 73140 KB | n=400000 |
26 | Correct | 100 ms | 42680 KB | n=285714 |
27 | Correct | 5 ms | 1496 KB | n=20000 |
28 | Correct | 57 ms | 20872 KB | n=181818 |
29 | Correct | 3 ms | 984 KB | n=10000 |
30 | Correct | 2 ms | 848 KB | n=6666 |
31 | Correct | 1 ms | 600 KB | n=4000 |
32 | Correct | 3 ms | 604 KB | n=2857 |
33 | Correct | 1 ms | 344 KB | n=2000 |
34 | Correct | 19 ms | 13332 KB | n=23514 |
35 | Correct | 19 ms | 13332 KB | n=23514 |
36 | Correct | 1 ms | 1116 KB | n=940 |
37 | Correct | 1 ms | 348 KB | n=2 |
38 | Correct | 37 ms | 17312 KB | n=100000 |
39 | Correct | 39 ms | 17292 KB | n=100000 |
40 | Correct | 0 ms | 348 KB | n=10 |
41 | Correct | 0 ms | 348 KB | n=100 |
42 | Correct | 2 ms | 604 KB | n=1000 |
43 | Runtime error | 509 ms | 524288 KB | Execution killed with signal 9 |
44 | Halted | 0 ms | 0 KB | - |