#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
using namespace std;
void solve(){
int n;cin>>n;
int k;cin>>k;
priority_queue<pii>q;
int sum=0;
for(int i=1;i<=n;i++){
int x;cin>>x;
q.push({x,i});
sum+=x;
}
if(sum%k){
cout<<-1;
return;
}
if(q.top().f>sum/k){
cout<<-1<<"\n";
return;
}
cout<<sum/k<<"\n";
while(!q.empty()){
vector<pii>vec;
int x=k;
while(x--){
pii a=q.top();
vec.pb(a);
q.pop();
}
cout<<1<<' ';
for(pii to:vec){
cout<<to.s<<' ';
if(to.f>1)
q.push({to.f-1,to.s});
}
cout<<"\n";
}
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);
int test=1;//cin>>test;
while(test--){
solve();
cout<<"\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
0 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 |
6 ms |
332 KB |
n=14 |
10 |
Correct |
3 ms |
332 KB |
n=11 |
11 |
Correct |
30 ms |
1736 KB |
n=50000 |
12 |
Correct |
26 ms |
1604 KB |
n=50000 |
13 |
Correct |
16 ms |
688 KB |
n=10 |
14 |
Correct |
19 ms |
716 KB |
n=685 |
15 |
Correct |
20 ms |
768 KB |
n=623 |
16 |
Correct |
11 ms |
588 KB |
n=973 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
6 ms |
332 KB |
n=14 |
10 |
Correct |
3 ms |
332 KB |
n=11 |
11 |
Correct |
30 ms |
1736 KB |
n=50000 |
12 |
Correct |
26 ms |
1604 KB |
n=50000 |
13 |
Correct |
16 ms |
688 KB |
n=10 |
14 |
Correct |
19 ms |
716 KB |
n=685 |
15 |
Correct |
20 ms |
768 KB |
n=623 |
16 |
Correct |
11 ms |
588 KB |
n=973 |
17 |
Correct |
20 ms |
716 KB |
n=989 |
18 |
Correct |
10 ms |
548 KB |
n=563 |
19 |
Correct |
15 ms |
604 KB |
n=592 |
20 |
Correct |
17 ms |
588 KB |
n=938 |
21 |
Correct |
12 ms |
588 KB |
n=747 |
22 |
Correct |
16 ms |
596 KB |
n=991 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
52 ms |
8632 KB |
Jury has the answer but participant has not |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
6 ms |
332 KB |
n=14 |
10 |
Correct |
3 ms |
332 KB |
n=11 |
11 |
Correct |
30 ms |
1736 KB |
n=50000 |
12 |
Correct |
26 ms |
1604 KB |
n=50000 |
13 |
Correct |
16 ms |
688 KB |
n=10 |
14 |
Correct |
19 ms |
716 KB |
n=685 |
15 |
Correct |
20 ms |
768 KB |
n=623 |
16 |
Correct |
11 ms |
588 KB |
n=973 |
17 |
Correct |
20 ms |
716 KB |
n=989 |
18 |
Correct |
10 ms |
548 KB |
n=563 |
19 |
Correct |
15 ms |
604 KB |
n=592 |
20 |
Correct |
17 ms |
588 KB |
n=938 |
21 |
Correct |
12 ms |
588 KB |
n=747 |
22 |
Correct |
16 ms |
596 KB |
n=991 |
23 |
Incorrect |
52 ms |
8632 KB |
Jury has the answer but participant has not |
24 |
Halted |
0 ms |
0 KB |
- |