# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
495218 | 2021-12-18T06:49:21 Z | Nalrimet | Gift (IZhO18_nicegift) | C++17 | 2000 ms | 524292 KB |
#include<bits/stdc++.h> using namespace std; const int N = 1e6 + 5; const int inf = 1000000000; #define F first #define S second #define pb push_back priority_queue<pair<int, int>> q; int n, k, a[N]; vector<int> v; vector<vector<int>> ans; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k; for(int i = 1; i <= n; ++i){ cin >> a[i]; q.push({a[i], i}); } while(!q.empty()){ if(q.size() < k){ cout << -1; exit(0); } for(int i = 1; i <= k; ++i){ v.push_back(q.top().S); q.pop(); } ans.pb(v); for(int i = 0; i < k; ++i){ a[v[i]]--; if(a[v[i]] != 0) q.push({a[v[i]], v[i]}); } v.clear(); } cout << ans.size() << '\n'; for(auto to : ans){ cout << 1 << ' '; for(auto to1 : to){ cout << to1 << ' '; } cout << '\n'; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | n=4 |
2 | Correct | 1 ms | 204 KB | n=3 |
3 | Correct | 0 ms | 204 KB | n=3 |
4 | Correct | 0 ms | 204 KB | n=4 |
5 | Correct | 0 ms | 204 KB | n=4 |
6 | Correct | 1 ms | 328 KB | n=2 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | n=4 |
2 | Correct | 1 ms | 204 KB | n=3 |
3 | Correct | 0 ms | 204 KB | n=3 |
4 | Correct | 0 ms | 204 KB | n=4 |
5 | Correct | 0 ms | 204 KB | n=4 |
6 | Correct | 1 ms | 328 KB | n=2 |
7 | Correct | 0 ms | 204 KB | n=5 |
8 | Correct | 1 ms | 972 KB | n=8 |
9 | Correct | 6 ms | 1160 KB | n=14 |
10 | Correct | 4 ms | 972 KB | n=11 |
11 | Correct | 28 ms | 4412 KB | n=50000 |
12 | Correct | 28 ms | 4496 KB | n=50000 |
13 | Correct | 20 ms | 3392 KB | n=10 |
14 | Correct | 23 ms | 3020 KB | n=685 |
15 | Correct | 27 ms | 3328 KB | n=623 |
16 | Correct | 16 ms | 1924 KB | n=973 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | n=4 |
2 | Correct | 1 ms | 204 KB | n=3 |
3 | Correct | 0 ms | 204 KB | n=3 |
4 | Correct | 0 ms | 204 KB | n=4 |
5 | Correct | 0 ms | 204 KB | n=4 |
6 | Correct | 1 ms | 328 KB | n=2 |
7 | Correct | 0 ms | 204 KB | n=5 |
8 | Correct | 1 ms | 972 KB | n=8 |
9 | Correct | 6 ms | 1160 KB | n=14 |
10 | Correct | 4 ms | 972 KB | n=11 |
11 | Correct | 28 ms | 4412 KB | n=50000 |
12 | Correct | 28 ms | 4496 KB | n=50000 |
13 | Correct | 20 ms | 3392 KB | n=10 |
14 | Correct | 23 ms | 3020 KB | n=685 |
15 | Correct | 27 ms | 3328 KB | n=623 |
16 | Correct | 16 ms | 1924 KB | n=973 |
17 | Correct | 21 ms | 2512 KB | n=989 |
18 | Correct | 10 ms | 976 KB | n=563 |
19 | Correct | 17 ms | 1292 KB | n=592 |
20 | Correct | 17 ms | 1360 KB | n=938 |
21 | Correct | 13 ms | 1020 KB | n=747 |
22 | Correct | 15 ms | 1092 KB | n=991 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2037 ms | 524292 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | n=4 |
2 | Correct | 1 ms | 204 KB | n=3 |
3 | Correct | 0 ms | 204 KB | n=3 |
4 | Correct | 0 ms | 204 KB | n=4 |
5 | Correct | 0 ms | 204 KB | n=4 |
6 | Correct | 1 ms | 328 KB | n=2 |
7 | Correct | 0 ms | 204 KB | n=5 |
8 | Correct | 1 ms | 972 KB | n=8 |
9 | Correct | 6 ms | 1160 KB | n=14 |
10 | Correct | 4 ms | 972 KB | n=11 |
11 | Correct | 28 ms | 4412 KB | n=50000 |
12 | Correct | 28 ms | 4496 KB | n=50000 |
13 | Correct | 20 ms | 3392 KB | n=10 |
14 | Correct | 23 ms | 3020 KB | n=685 |
15 | Correct | 27 ms | 3328 KB | n=623 |
16 | Correct | 16 ms | 1924 KB | n=973 |
17 | Correct | 21 ms | 2512 KB | n=989 |
18 | Correct | 10 ms | 976 KB | n=563 |
19 | Correct | 17 ms | 1292 KB | n=592 |
20 | Correct | 17 ms | 1360 KB | n=938 |
21 | Correct | 13 ms | 1020 KB | n=747 |
22 | Correct | 15 ms | 1092 KB | n=991 |
23 | Execution timed out | 2037 ms | 524292 KB | Time limit exceeded |
24 | Halted | 0 ms | 0 KB | - |