#include<bits/stdc++.h>
using namespace std;
int n,k;
int a[1000005];
int sc[1000005];
priority_queue<pair<int,int>> pq;
signed main()
{
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n>>k;
int sum=0;
for(int i=1;i<=n;i++)
{
cin>>a[i];
sum += a[i];
pq.push({a[i],i});
}
if(sum%k!=0)
{
cout<<-1;
return 0;
}
cout<<sum/k<<"\n";
while(!pq.empty())
{
cout<<1<<" ";
for(int i=0;i<k;i++)
{
sc[i]=pq.top().second;
pq.pop();
a[sc[i]]--;
cout<<sc[i]<<" ";
}
cout<<"\n";
for(int i=0;i<k;i++)
if(a[sc[i]]>0)
pq.push({a[sc[i]],sc[i]});
}
return 0;
}
/**
4 2
2 3 3 2
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 8 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
3552 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
3552 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 8 |
2 |
Halted |
0 ms |
0 KB |
- |