# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
52023 | 2018-06-23T09:41:03 Z | mrtsima22 | Gift (IZhO18_nicegift) | C++17 | 2000 ms | 167268 KB |
#include <bits/stdc++.h> using namespace std; #define lo long const int lmax=1999999999; const long long lmx=1999999999999999999; int n,k; long long a[1000003],sum,p; set<pair<long long,int> >s; vector<vector<int> > ans; int main(){std::ios::sync_with_stdio(false); cin>>n>>k; for(int i=1;i<=n;i++) { cin>>a[i]; sum=sum+a[i]; } if(sum%k!=0){ cout<<-1<<endl;return 0;} for(int i=1;i<=n;i++) { s.insert(make_pair(a[i],i)); } p=1; while(s.size()) { int t=0; vector<int>v; while(s.size()&&t<k) { set<pair<long long,int> >::iterator it=s.end(); it--; int u=(*(it)).second; s.erase(it); v.push_back(u); a[u]-=p; t++; } if(t!=k){cout<<-1<<endl;return 0; } for(int i=0;i<v.size();i++) { if(a[v[i]]>0) { s.insert(make_pair(a[v[i]],v[i])); } } ans.push_back(v); } cout<<ans.size()<<endl; for(int i=0;i<ans.size();i++) { cout<<p<<" "; for(int j=0;j<ans[i].size();j++) { cout<<ans[i][j]<<" "; } cout<<endl; } } /* 70. 71. * * 72. * * * * 73. * * * * 74. * * * * 75. * * * * 76. * * * 77. * * 78. * * 79. * * 80. * * 81. * * 82. * * 83. * * 84. * * 85. * 86. 87. 88. 89.*/
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | n=4 |
2 | Correct | 2 ms | 360 KB | n=3 |
3 | Correct | 2 ms | 400 KB | n=3 |
4 | Correct | 2 ms | 420 KB | n=4 |
5 | Correct | 2 ms | 512 KB | n=4 |
6 | Correct | 3 ms | 536 KB | n=2 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | n=4 |
2 | Correct | 2 ms | 360 KB | n=3 |
3 | Correct | 2 ms | 400 KB | n=3 |
4 | Correct | 2 ms | 420 KB | n=4 |
5 | Correct | 2 ms | 512 KB | n=4 |
6 | Correct | 3 ms | 536 KB | n=2 |
7 | Correct | 2 ms | 648 KB | n=5 |
8 | Correct | 6 ms | 1192 KB | n=8 |
9 | Correct | 30 ms | 1640 KB | n=14 |
10 | Correct | 20 ms | 1640 KB | n=11 |
11 | Correct | 122 ms | 6860 KB | n=50000 |
12 | Correct | 123 ms | 7112 KB | n=50000 |
13 | Correct | 102 ms | 7112 KB | n=10 |
14 | Correct | 89 ms | 7112 KB | n=685 |
15 | Correct | 106 ms | 7112 KB | n=623 |
16 | Correct | 55 ms | 7112 KB | n=973 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | n=4 |
2 | Correct | 2 ms | 360 KB | n=3 |
3 | Correct | 2 ms | 400 KB | n=3 |
4 | Correct | 2 ms | 420 KB | n=4 |
5 | Correct | 2 ms | 512 KB | n=4 |
6 | Correct | 3 ms | 536 KB | n=2 |
7 | Correct | 2 ms | 648 KB | n=5 |
8 | Correct | 6 ms | 1192 KB | n=8 |
9 | Correct | 30 ms | 1640 KB | n=14 |
10 | Correct | 20 ms | 1640 KB | n=11 |
11 | Correct | 122 ms | 6860 KB | n=50000 |
12 | Correct | 123 ms | 7112 KB | n=50000 |
13 | Correct | 102 ms | 7112 KB | n=10 |
14 | Correct | 89 ms | 7112 KB | n=685 |
15 | Correct | 106 ms | 7112 KB | n=623 |
16 | Correct | 55 ms | 7112 KB | n=973 |
17 | Correct | 80 ms | 7112 KB | n=989 |
18 | Correct | 25 ms | 7112 KB | n=563 |
19 | Correct | 31 ms | 7112 KB | n=592 |
20 | Correct | 34 ms | 7112 KB | n=938 |
21 | Correct | 29 ms | 7112 KB | n=747 |
22 | Correct | 30 ms | 7112 KB | n=991 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2069 ms | 167268 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | n=4 |
2 | Correct | 2 ms | 360 KB | n=3 |
3 | Correct | 2 ms | 400 KB | n=3 |
4 | Correct | 2 ms | 420 KB | n=4 |
5 | Correct | 2 ms | 512 KB | n=4 |
6 | Correct | 3 ms | 536 KB | n=2 |
7 | Correct | 2 ms | 648 KB | n=5 |
8 | Correct | 6 ms | 1192 KB | n=8 |
9 | Correct | 30 ms | 1640 KB | n=14 |
10 | Correct | 20 ms | 1640 KB | n=11 |
11 | Correct | 122 ms | 6860 KB | n=50000 |
12 | Correct | 123 ms | 7112 KB | n=50000 |
13 | Correct | 102 ms | 7112 KB | n=10 |
14 | Correct | 89 ms | 7112 KB | n=685 |
15 | Correct | 106 ms | 7112 KB | n=623 |
16 | Correct | 55 ms | 7112 KB | n=973 |
17 | Correct | 80 ms | 7112 KB | n=989 |
18 | Correct | 25 ms | 7112 KB | n=563 |
19 | Correct | 31 ms | 7112 KB | n=592 |
20 | Correct | 34 ms | 7112 KB | n=938 |
21 | Correct | 29 ms | 7112 KB | n=747 |
22 | Correct | 30 ms | 7112 KB | n=991 |
23 | Execution timed out | 2069 ms | 167268 KB | Time limit exceeded |
24 | Halted | 0 ms | 0 KB | - |