# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
92768 | 2019-01-04T13:15:25 Z | Vardanyan | Gift (IZhO18_nicegift) | C++14 | 513 ms | 55092 KB |
#include<bits/stdc++.h> using namespace std; const int N = 1000*1000+5; pair<int,int> a[N]; int main() { int n,k; scanf("%d%d",&n,&k); int sum = 0; set<pair<int,int >,greater<pair<int,int> > > ms; for(int i = 1;i<=n;i++){ scanf("%d",&a[i].first); a[i].second = i; sum+=a[i].first; ms.insert(a[i]); } sort(a+1,a+1+n); vector<vector<int> > ans; while(1){ int kk = k; vector<int> now; set<pair<int,int> >::iterator it = ms.begin(); vector<pair<int,int> > add; for(;it!=ms.end();it++){ pair<int,int> x = *it; if(x.first<=0){ printf("-1\n"); return 0; } //x.first--; sum--; now.push_back(x.second); kk--; add.push_back(x); if(kk == 0) break; } for(int i = 0;i<add.size();i++){ ms.erase(ms.find(add[i])); add[i].first--; ms.insert(add[i]); } ans.push_back(now); if(sum == 0) break; } printf("%d\n",ans.size()); for(int i = 0;i<ans.size();i++){ printf("1 "); for(int j = 0;j<ans[i].size();j++){ printf("%d ",ans[i][j]); } printf("\n"); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | n=4 |
2 | Correct | 2 ms | 256 KB | n=3 |
3 | Correct | 2 ms | 256 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 256 KB | n=4 |
6 | Correct | 2 ms | 256 KB | n=2 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | n=4 |
2 | Correct | 2 ms | 256 KB | n=3 |
3 | Correct | 2 ms | 256 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 256 KB | n=4 |
6 | Correct | 2 ms | 256 KB | n=2 |
7 | Correct | 2 ms | 376 KB | n=5 |
8 | Correct | 5 ms | 1016 KB | n=8 |
9 | Correct | 10 ms | 1200 KB | n=14 |
10 | Correct | 6 ms | 1016 KB | n=11 |
11 | Correct | 68 ms | 6600 KB | n=50000 |
12 | Correct | 70 ms | 6696 KB | n=50000 |
13 | Correct | 30 ms | 3496 KB | n=10 |
14 | Correct | 31 ms | 3064 KB | n=685 |
15 | Correct | 33 ms | 3368 KB | n=623 |
16 | Correct | 20 ms | 2092 KB | n=973 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | n=4 |
2 | Correct | 2 ms | 256 KB | n=3 |
3 | Correct | 2 ms | 256 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 256 KB | n=4 |
6 | Correct | 2 ms | 256 KB | n=2 |
7 | Correct | 2 ms | 376 KB | n=5 |
8 | Correct | 5 ms | 1016 KB | n=8 |
9 | Correct | 10 ms | 1200 KB | n=14 |
10 | Correct | 6 ms | 1016 KB | n=11 |
11 | Correct | 68 ms | 6600 KB | n=50000 |
12 | Correct | 70 ms | 6696 KB | n=50000 |
13 | Correct | 30 ms | 3496 KB | n=10 |
14 | Correct | 31 ms | 3064 KB | n=685 |
15 | Correct | 33 ms | 3368 KB | n=623 |
16 | Correct | 20 ms | 2092 KB | n=973 |
17 | Correct | 33 ms | 2612 KB | n=989 |
18 | Correct | 15 ms | 1016 KB | n=563 |
19 | Correct | 24 ms | 1404 KB | n=592 |
20 | Correct | 24 ms | 1500 KB | n=938 |
21 | Correct | 19 ms | 1144 KB | n=747 |
22 | Correct | 22 ms | 1272 KB | n=991 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 513 ms | 55092 KB | Jury has the answer but participant has not |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | n=4 |
2 | Correct | 2 ms | 256 KB | n=3 |
3 | Correct | 2 ms | 256 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 256 KB | n=4 |
6 | Correct | 2 ms | 256 KB | n=2 |
7 | Correct | 2 ms | 376 KB | n=5 |
8 | Correct | 5 ms | 1016 KB | n=8 |
9 | Correct | 10 ms | 1200 KB | n=14 |
10 | Correct | 6 ms | 1016 KB | n=11 |
11 | Correct | 68 ms | 6600 KB | n=50000 |
12 | Correct | 70 ms | 6696 KB | n=50000 |
13 | Correct | 30 ms | 3496 KB | n=10 |
14 | Correct | 31 ms | 3064 KB | n=685 |
15 | Correct | 33 ms | 3368 KB | n=623 |
16 | Correct | 20 ms | 2092 KB | n=973 |
17 | Correct | 33 ms | 2612 KB | n=989 |
18 | Correct | 15 ms | 1016 KB | n=563 |
19 | Correct | 24 ms | 1404 KB | n=592 |
20 | Correct | 24 ms | 1500 KB | n=938 |
21 | Correct | 19 ms | 1144 KB | n=747 |
22 | Correct | 22 ms | 1272 KB | n=991 |
23 | Incorrect | 513 ms | 55092 KB | Jury has the answer but participant has not |
24 | Halted | 0 ms | 0 KB | - |