# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
484828 | 2021-11-05T14:57:47 Z | luka1234 | Gift (IZhO18_nicegift) | C++14 | 250 ms | 47260 KB |
#include<bits/stdc++.h> #define ll long long #define ff first #define ss second using namespace std; int n,m; set<pair<int,int> > s; int a[1000001]; vector<vector<int> > ans; int sum=0; int main(){ cin>>n>>m; for(int k=1;k<=n;k++){ cin>>a[k]; s.insert({a[k],k}); sum+=a[k]; } if(sum%m!=0){ cout<<-1; return 0; } int bolo=(*s.rbegin()).ff; if(bolo>(sum/m)){ cout<<-1; return 0; } while(!s.empty()){ vector<pair<int,int> > chamateba; int sz=s.size(); while(s.size()>(sz-m)){ pair<int,int> f=*s.rbegin(); s.erase(*s.rbegin()); chamateba.push_back(f); } vector<int> ans1; ans1.push_back(1); for(int k=0;k<chamateba.size();k++){ pair<int,int> f=chamateba[k]; ans1.push_back(f.ss); f.ff--; if(f.ff!=0) s.insert(f); } ans.push_back(ans1); } cout<<ans.size()<<"\n"; for(int k=0;k<ans.size();k++){ for(int i=0;i<ans[k].size();i++){ cout<<ans[k][i]<<' '; } cout<<"\n"; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | n=4 |
2 | Correct | 0 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 | 0 ms | 204 KB | n=2 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | n=4 |
2 | Correct | 0 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 | 0 ms | 204 KB | n=2 |
7 | Correct | 0 ms | 204 KB | n=5 |
8 | Correct | 0 ms | 204 KB | n=8 |
9 | Correct | 9 ms | 1160 KB | n=14 |
10 | Correct | 6 ms | 844 KB | n=11 |
11 | Correct | 56 ms | 5324 KB | n=50000 |
12 | Correct | 66 ms | 5540 KB | n=50000 |
13 | Correct | 31 ms | 3416 KB | n=10 |
14 | Correct | 31 ms | 3036 KB | n=685 |
15 | Correct | 34 ms | 3320 KB | n=623 |
16 | Correct | 21 ms | 1936 KB | n=973 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | n=4 |
2 | Correct | 0 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 | 0 ms | 204 KB | n=2 |
7 | Correct | 0 ms | 204 KB | n=5 |
8 | Correct | 0 ms | 204 KB | n=8 |
9 | Correct | 9 ms | 1160 KB | n=14 |
10 | Correct | 6 ms | 844 KB | n=11 |
11 | Correct | 56 ms | 5324 KB | n=50000 |
12 | Correct | 66 ms | 5540 KB | n=50000 |
13 | Correct | 31 ms | 3416 KB | n=10 |
14 | Correct | 31 ms | 3036 KB | n=685 |
15 | Correct | 34 ms | 3320 KB | n=623 |
16 | Correct | 21 ms | 1936 KB | n=973 |
17 | Correct | 40 ms | 2432 KB | n=989 |
18 | Correct | 15 ms | 972 KB | n=563 |
19 | Correct | 25 ms | 1252 KB | n=592 |
20 | Correct | 28 ms | 1284 KB | n=938 |
21 | Correct | 20 ms | 1100 KB | n=747 |
22 | Correct | 23 ms | 1108 KB | n=991 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 250 ms | 47260 KB | Jury has the answer but participant has not |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | n=4 |
2 | Correct | 0 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 | 0 ms | 204 KB | n=2 |
7 | Correct | 0 ms | 204 KB | n=5 |
8 | Correct | 0 ms | 204 KB | n=8 |
9 | Correct | 9 ms | 1160 KB | n=14 |
10 | Correct | 6 ms | 844 KB | n=11 |
11 | Correct | 56 ms | 5324 KB | n=50000 |
12 | Correct | 66 ms | 5540 KB | n=50000 |
13 | Correct | 31 ms | 3416 KB | n=10 |
14 | Correct | 31 ms | 3036 KB | n=685 |
15 | Correct | 34 ms | 3320 KB | n=623 |
16 | Correct | 21 ms | 1936 KB | n=973 |
17 | Correct | 40 ms | 2432 KB | n=989 |
18 | Correct | 15 ms | 972 KB | n=563 |
19 | Correct | 25 ms | 1252 KB | n=592 |
20 | Correct | 28 ms | 1284 KB | n=938 |
21 | Correct | 20 ms | 1100 KB | n=747 |
22 | Correct | 23 ms | 1108 KB | n=991 |
23 | Incorrect | 250 ms | 47260 KB | Jury has the answer but participant has not |
24 | Halted | 0 ms | 0 KB | - |