#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;
set<pair<ll, ll> > a;
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++)
{
ll x;
cin>>x;
a.insert({x, i});
}
while(!a.empty())
{
vector<ll> q;
/*for(ll i=1; i<=n; i++)
cout<<a[i].fr<<" ";
cout<<endl;*/
if(a.size()-k<0 || v.size()*k>3000000)
{
cout<<-1;
return 0;
}
std::vector<pair<ll, ll> > y;
for(ll j=1; j<=k; j++)
{
std::pair<ll, ll> x;
x=*a.rbegin();
a.erase(x);
q.push_back(x.se);
x.fr--;
if(x.fr)
y.push_back(x);
}
for(ll i=0; i<y.size(); i++)
a.insert(y[i]);
v.push_back({1, q});
}
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:62:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(ll i=0; i<y.size(); i++)
~^~~~~~~~~
nicegift.cpp:69:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(ll i=0; i<v.size(); i++)
~^~~~~~~~~
nicegift.cpp:72:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(ll j=0; j<v[i].se.size(); j++)
~^~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n=4 |
2 |
Correct |
2 ms |
508 KB |
n=3 |
3 |
Runtime error |
3 ms |
672 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n=4 |
2 |
Correct |
2 ms |
508 KB |
n=3 |
3 |
Runtime error |
3 ms |
672 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n=4 |
2 |
Correct |
2 ms |
508 KB |
n=3 |
3 |
Runtime error |
3 ms |
672 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2021 ms |
118376 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n=4 |
2 |
Correct |
2 ms |
508 KB |
n=3 |
3 |
Runtime error |
3 ms |
672 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |