# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
40451 | 2018-02-01T15:11:06 Z | szawinis | Gift (IZhO18_nicegift) | C++14 | 206 ms | 28136 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1e6+1; int n, k, a[N]; vector<int> ls[N]; int main() { scanf("%d %d", &n, &k); int sum = 0; for(int i = 0; i < n; i++) scanf("%d", a+i), sum += a[i]; if(sum % k) printf("-1"), exit(0); priority_queue<pair<int,int> > pq; for(int i = 0; i < sum / k; i++) pq.emplace(k, i); for(int i = 0; i < n; i++) { unordered_set<int> mark; for(int j = 0; j < a[i]; j++) { assert(!pq.empty()); auto curr = pq.top(); pq.pop(); --curr.first; if(mark.count(curr.second)) printf("-1"), exit(0); ls[curr.second].push_back(i); pq.push(curr); mark.insert(curr.second); } } printf("%d\n", sum / k); for(int i = 0; i < sum / k; i++) { assert(ls[i].size() == k); printf("1 "); for(int idx: ls[i]) printf("%d ", idx+1); printf("\n"); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 23800 KB | n=4 |
2 | Correct | 20 ms | 23912 KB | n=3 |
3 | Correct | 20 ms | 23980 KB | n=3 |
4 | Correct | 19 ms | 23980 KB | n=4 |
5 | Correct | 19 ms | 23980 KB | n=4 |
6 | Correct | 19 ms | 24024 KB | n=2 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 23800 KB | n=4 |
2 | Correct | 20 ms | 23912 KB | n=3 |
3 | Correct | 20 ms | 23980 KB | n=3 |
4 | Correct | 19 ms | 23980 KB | n=4 |
5 | Correct | 19 ms | 23980 KB | n=4 |
6 | Correct | 19 ms | 24024 KB | n=2 |
7 | Correct | 19 ms | 24024 KB | n=5 |
8 | Correct | 33 ms | 27088 KB | n=8 |
9 | Correct | 35 ms | 27088 KB | n=14 |
10 | Correct | 27 ms | 27088 KB | n=11 |
11 | Correct | 71 ms | 28136 KB | n=50000 |
12 | Correct | 75 ms | 28136 KB | n=50000 |
13 | Correct | 62 ms | 28136 KB | n=10 |
14 | Correct | 56 ms | 28136 KB | n=685 |
15 | Correct | 58 ms | 28136 KB | n=623 |
16 | Correct | 43 ms | 28136 KB | n=973 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 23800 KB | n=4 |
2 | Correct | 20 ms | 23912 KB | n=3 |
3 | Correct | 20 ms | 23980 KB | n=3 |
4 | Correct | 19 ms | 23980 KB | n=4 |
5 | Correct | 19 ms | 23980 KB | n=4 |
6 | Correct | 19 ms | 24024 KB | n=2 |
7 | Correct | 19 ms | 24024 KB | n=5 |
8 | Correct | 33 ms | 27088 KB | n=8 |
9 | Correct | 35 ms | 27088 KB | n=14 |
10 | Correct | 27 ms | 27088 KB | n=11 |
11 | Correct | 71 ms | 28136 KB | n=50000 |
12 | Correct | 75 ms | 28136 KB | n=50000 |
13 | Correct | 62 ms | 28136 KB | n=10 |
14 | Correct | 56 ms | 28136 KB | n=685 |
15 | Correct | 58 ms | 28136 KB | n=623 |
16 | Correct | 43 ms | 28136 KB | n=973 |
17 | Correct | 58 ms | 28136 KB | n=989 |
18 | Correct | 38 ms | 28136 KB | n=563 |
19 | Correct | 50 ms | 28136 KB | n=592 |
20 | Correct | 60 ms | 28136 KB | n=938 |
21 | Correct | 45 ms | 28136 KB | n=747 |
22 | Correct | 48 ms | 28136 KB | n=991 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 206 ms | 28136 KB | Not all heaps are empty in the end |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 23800 KB | n=4 |
2 | Correct | 20 ms | 23912 KB | n=3 |
3 | Correct | 20 ms | 23980 KB | n=3 |
4 | Correct | 19 ms | 23980 KB | n=4 |
5 | Correct | 19 ms | 23980 KB | n=4 |
6 | Correct | 19 ms | 24024 KB | n=2 |
7 | Correct | 19 ms | 24024 KB | n=5 |
8 | Correct | 33 ms | 27088 KB | n=8 |
9 | Correct | 35 ms | 27088 KB | n=14 |
10 | Correct | 27 ms | 27088 KB | n=11 |
11 | Correct | 71 ms | 28136 KB | n=50000 |
12 | Correct | 75 ms | 28136 KB | n=50000 |
13 | Correct | 62 ms | 28136 KB | n=10 |
14 | Correct | 56 ms | 28136 KB | n=685 |
15 | Correct | 58 ms | 28136 KB | n=623 |
16 | Correct | 43 ms | 28136 KB | n=973 |
17 | Correct | 58 ms | 28136 KB | n=989 |
18 | Correct | 38 ms | 28136 KB | n=563 |
19 | Correct | 50 ms | 28136 KB | n=592 |
20 | Correct | 60 ms | 28136 KB | n=938 |
21 | Correct | 45 ms | 28136 KB | n=747 |
22 | Correct | 48 ms | 28136 KB | n=991 |
23 | Incorrect | 206 ms | 28136 KB | Not all heaps are empty in the end |
24 | Halted | 0 ms | 0 KB | - |