#include <bits/stdc++.h>
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
int it[1000001];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,k;
cin>>n>>k;
priority_queue<pair<int,int>> x;
for(int i=0;i<n;i++){
cin>>it[i];
if(it[i]>0){
x.push({it[i],i});
}
}
int st=0;
vector<vector<int>> ans;
while(x.size()){
if(x.size()<k){
st=1;
break;
}
ans.pb({});
vector<pair<int,int>> kk;
for(int i=0;i<k;i++){
pair<int,int> no=x.top();
x.pop();
ans.back().pb(no.b);
kk.pb(no);
}
for(auto j:kk){
if(j.a>1){
x.push({j.a-1,j.b});
}
}
}
if(st){
cout<<-1<<endl;
}
else{
cout<<ans.size()<<endl;
for(auto j:ans){
cout<<1<<" ";
for(auto i:j){
cout<<i+1<<" ";
}
cout<<endl;
}
}
return 0;
}
Compilation message
nicegift.cpp: In function 'int main()':
nicegift.cpp:24:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(x.size()<k){
~~~~~~~~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
n=4 |
2 |
Correct |
5 ms |
384 KB |
n=3 |
3 |
Correct |
5 ms |
384 KB |
n=3 |
4 |
Correct |
5 ms |
384 KB |
n=4 |
5 |
Correct |
5 ms |
396 KB |
n=4 |
6 |
Correct |
5 ms |
384 KB |
n=2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
n=4 |
2 |
Correct |
5 ms |
384 KB |
n=3 |
3 |
Correct |
5 ms |
384 KB |
n=3 |
4 |
Correct |
5 ms |
384 KB |
n=4 |
5 |
Correct |
5 ms |
396 KB |
n=4 |
6 |
Correct |
5 ms |
384 KB |
n=2 |
7 |
Correct |
5 ms |
384 KB |
n=5 |
8 |
Correct |
7 ms |
1024 KB |
n=8 |
9 |
Correct |
38 ms |
1212 KB |
n=14 |
10 |
Correct |
33 ms |
1152 KB |
n=11 |
11 |
Correct |
140 ms |
4584 KB |
n=50000 |
12 |
Correct |
133 ms |
4460 KB |
n=50000 |
13 |
Correct |
122 ms |
3496 KB |
n=10 |
14 |
Correct |
114 ms |
3160 KB |
n=685 |
15 |
Correct |
120 ms |
3332 KB |
n=623 |
16 |
Correct |
67 ms |
2096 KB |
n=973 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
n=4 |
2 |
Correct |
5 ms |
384 KB |
n=3 |
3 |
Correct |
5 ms |
384 KB |
n=3 |
4 |
Correct |
5 ms |
384 KB |
n=4 |
5 |
Correct |
5 ms |
396 KB |
n=4 |
6 |
Correct |
5 ms |
384 KB |
n=2 |
7 |
Correct |
5 ms |
384 KB |
n=5 |
8 |
Correct |
7 ms |
1024 KB |
n=8 |
9 |
Correct |
38 ms |
1212 KB |
n=14 |
10 |
Correct |
33 ms |
1152 KB |
n=11 |
11 |
Correct |
140 ms |
4584 KB |
n=50000 |
12 |
Correct |
133 ms |
4460 KB |
n=50000 |
13 |
Correct |
122 ms |
3496 KB |
n=10 |
14 |
Correct |
114 ms |
3160 KB |
n=685 |
15 |
Correct |
120 ms |
3332 KB |
n=623 |
16 |
Correct |
67 ms |
2096 KB |
n=973 |
17 |
Correct |
97 ms |
2608 KB |
n=989 |
18 |
Correct |
29 ms |
1024 KB |
n=563 |
19 |
Correct |
32 ms |
1528 KB |
n=592 |
20 |
Correct |
36 ms |
1400 KB |
n=938 |
21 |
Correct |
34 ms |
1404 KB |
n=747 |
22 |
Correct |
34 ms |
1280 KB |
n=991 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
384 KB |
Jury has the answer but participant has not |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
n=4 |
2 |
Correct |
5 ms |
384 KB |
n=3 |
3 |
Correct |
5 ms |
384 KB |
n=3 |
4 |
Correct |
5 ms |
384 KB |
n=4 |
5 |
Correct |
5 ms |
396 KB |
n=4 |
6 |
Correct |
5 ms |
384 KB |
n=2 |
7 |
Correct |
5 ms |
384 KB |
n=5 |
8 |
Correct |
7 ms |
1024 KB |
n=8 |
9 |
Correct |
38 ms |
1212 KB |
n=14 |
10 |
Correct |
33 ms |
1152 KB |
n=11 |
11 |
Correct |
140 ms |
4584 KB |
n=50000 |
12 |
Correct |
133 ms |
4460 KB |
n=50000 |
13 |
Correct |
122 ms |
3496 KB |
n=10 |
14 |
Correct |
114 ms |
3160 KB |
n=685 |
15 |
Correct |
120 ms |
3332 KB |
n=623 |
16 |
Correct |
67 ms |
2096 KB |
n=973 |
17 |
Correct |
97 ms |
2608 KB |
n=989 |
18 |
Correct |
29 ms |
1024 KB |
n=563 |
19 |
Correct |
32 ms |
1528 KB |
n=592 |
20 |
Correct |
36 ms |
1400 KB |
n=938 |
21 |
Correct |
34 ms |
1404 KB |
n=747 |
22 |
Correct |
34 ms |
1280 KB |
n=991 |
23 |
Incorrect |
13 ms |
384 KB |
Jury has the answer but participant has not |
24 |
Halted |
0 ms |
0 KB |
- |