#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define st string
#define fr first
#define se second
const ll mod=1e9+7;
using namespace std;
pair<ll, ll> a[1000100];
vector<pair<ll, vector<ll> > > v;
int main()
{
//freopen("1.txt", "r", stdin);
//freopen("1.txt", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
ll n, k;
cin>>n>>k;
for(ll i=1; i<=n; i++)
{
cin>>a[i].fr;
a[i].se=i;
}
sort(a+1, a+1+n);
while(a[n].fr)
{
vector<ll> q;
/*for(ll i=1; i<=n; i++)
cout<<a[i].fr<<" ";
cout<<endl;*/
if(!a[n-k+1].fr)
{
cout<<-1;
return 0;
}
for(ll j=n; j>=n-k+1; j--)
{
q.push_back(a[j].se);
a[j].fr--;
}
v.push_back({1, q});
sort(a+1, a+1+n);
}
cout<<v.size()<<endl;
for(ll i=0; i<v.size(); i++)
{
cout<<v[i].fr<<" ";
for(ll j=0; j<v[i].se.size(); j++)
{
cout<<v[i].se[j]<<" ";
}
cout<<endl;
}
return 0;
}
/*
*/
Compilation message
nicegift.cpp: In function 'int main()':
nicegift.cpp:59:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(ll i=0; i<v.size(); i++)
~^~~~~~~~~
nicegift.cpp:62:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(ll j=0; j<v[i].se.size(); j++)
~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n=4 |
2 |
Correct |
2 ms |
516 KB |
n=3 |
3 |
Correct |
3 ms |
516 KB |
n=3 |
4 |
Correct |
2 ms |
516 KB |
n=4 |
5 |
Correct |
2 ms |
516 KB |
n=4 |
6 |
Correct |
4 ms |
516 KB |
n=2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n=4 |
2 |
Correct |
2 ms |
516 KB |
n=3 |
3 |
Correct |
3 ms |
516 KB |
n=3 |
4 |
Correct |
2 ms |
516 KB |
n=4 |
5 |
Correct |
2 ms |
516 KB |
n=4 |
6 |
Correct |
4 ms |
516 KB |
n=2 |
7 |
Correct |
2 ms |
516 KB |
n=5 |
8 |
Correct |
5 ms |
1296 KB |
n=8 |
9 |
Correct |
31 ms |
1664 KB |
n=14 |
10 |
Correct |
20 ms |
1664 KB |
n=11 |
11 |
Execution timed out |
2032 ms |
1668 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n=4 |
2 |
Correct |
2 ms |
516 KB |
n=3 |
3 |
Correct |
3 ms |
516 KB |
n=3 |
4 |
Correct |
2 ms |
516 KB |
n=4 |
5 |
Correct |
2 ms |
516 KB |
n=4 |
6 |
Correct |
4 ms |
516 KB |
n=2 |
7 |
Correct |
2 ms |
516 KB |
n=5 |
8 |
Correct |
5 ms |
1296 KB |
n=8 |
9 |
Correct |
31 ms |
1664 KB |
n=14 |
10 |
Correct |
20 ms |
1664 KB |
n=11 |
11 |
Execution timed out |
2032 ms |
1668 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2069 ms |
16384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n=4 |
2 |
Correct |
2 ms |
516 KB |
n=3 |
3 |
Correct |
3 ms |
516 KB |
n=3 |
4 |
Correct |
2 ms |
516 KB |
n=4 |
5 |
Correct |
2 ms |
516 KB |
n=4 |
6 |
Correct |
4 ms |
516 KB |
n=2 |
7 |
Correct |
2 ms |
516 KB |
n=5 |
8 |
Correct |
5 ms |
1296 KB |
n=8 |
9 |
Correct |
31 ms |
1664 KB |
n=14 |
10 |
Correct |
20 ms |
1664 KB |
n=11 |
11 |
Execution timed out |
2032 ms |
1668 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |