#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second
using namespace std;
const int N = 5e5 + 5, INF = 1e9 + 5;
int n, k;
pair < int, int > P[N];
int nn;
vector < int > V[N], v;
int S;
int main()
{
ios::sync_with_stdio(false);
cin>>n>>k;
for (int i = 1; i <= n; i++){
cin>>P[i].F;
P[i].S = i;
S += P[i].F;
}
sort (P + 1, P + n + 1);
reverse (P + 1, P + n + 1);
if (S <= 1e5){
while (P[1].F > 0){
int I1 = k, I2 = k;
for (int i = 20; i >= 0; i--){
if (I1 - (1<<i) <= 0)
continue;
if (P[I1 - (1<<i)].F == P[k].F)
I1 -= (1<<i);
}
for (int i = 20; i >= 0; i--){
if (I2 + (1<<i) > n)
continue;
if (P[I2 + (1<<i)].F == P[k].F)
I2 += (1<<i);
}
v.clear();
for (int i = 1; i < I1; i++){
v.pb (P[i].S);
P[i].F--;
}
for (int i = I2; (int)v.size() < k; i--){
v.pb (P[i].S);
P[i].F--;
}
V[++nn] = v;
}
cout<<nn<<endl;
for (int i = 1; i <= nn; i++){
cout<<"1 ";
for (int j = 0; j < k; j++)
cout<<V[i][j]<<" ";
cout<<endl;
}
return 0;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
12152 KB |
n=4 |
2 |
Correct |
12 ms |
12152 KB |
n=3 |
3 |
Incorrect |
13 ms |
12152 KB |
Taken too much stones from the heap |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
12152 KB |
n=4 |
2 |
Correct |
12 ms |
12152 KB |
n=3 |
3 |
Incorrect |
13 ms |
12152 KB |
Taken too much stones from the heap |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
12152 KB |
n=4 |
2 |
Correct |
12 ms |
12152 KB |
n=3 |
3 |
Incorrect |
13 ms |
12152 KB |
Taken too much stones from the heap |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
24 ms |
16036 KB |
Not all heaps are empty in the end |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
12152 KB |
n=4 |
2 |
Correct |
12 ms |
12152 KB |
n=3 |
3 |
Incorrect |
13 ms |
12152 KB |
Taken too much stones from the heap |
4 |
Halted |
0 ms |
0 KB |
- |