#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second
using namespace std;
const ll N=1000006;
ll n, k, x, s, mx;
pair<int, int> a[N];
priority_queue<pair<int,int> > q;
int main(){ios_base::sync_with_stdio(false), cin.tie(0);
cin>>n>>k;
for(int i=0;i<n;i++)
cin>>x, s+=x,
mx=max(mx,x),
q.push({x,i+1});
if(s%k||k*mx>s){cout<<-1; return 0;}
cout<<s/k<<'\n';
while(!q.empty()){
cout<<1<<" ";
for(int i=0;i<k;i++)
a[i]=q.top(),
q.pop();
for(int i=0;i<k;i++){
if(a[i].F>1)q.push({a[i].F-1, a[i].S});
cout<<a[i].S<<" ";
}
cout<<'\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Correct |
1 ms |
364 KB |
n=8 |
9 |
Correct |
6 ms |
492 KB |
n=14 |
10 |
Correct |
4 ms |
364 KB |
n=11 |
11 |
Correct |
32 ms |
1764 KB |
n=50000 |
12 |
Correct |
31 ms |
1644 KB |
n=50000 |
13 |
Correct |
18 ms |
748 KB |
n=10 |
14 |
Correct |
20 ms |
876 KB |
n=685 |
15 |
Correct |
22 ms |
876 KB |
n=623 |
16 |
Correct |
13 ms |
620 KB |
n=973 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Correct |
1 ms |
364 KB |
n=8 |
9 |
Correct |
6 ms |
492 KB |
n=14 |
10 |
Correct |
4 ms |
364 KB |
n=11 |
11 |
Correct |
32 ms |
1764 KB |
n=50000 |
12 |
Correct |
31 ms |
1644 KB |
n=50000 |
13 |
Correct |
18 ms |
748 KB |
n=10 |
14 |
Correct |
20 ms |
876 KB |
n=685 |
15 |
Correct |
22 ms |
876 KB |
n=623 |
16 |
Correct |
13 ms |
620 KB |
n=973 |
17 |
Correct |
20 ms |
876 KB |
n=989 |
18 |
Correct |
10 ms |
620 KB |
n=563 |
19 |
Correct |
16 ms |
748 KB |
n=592 |
20 |
Correct |
17 ms |
748 KB |
n=938 |
21 |
Correct |
13 ms |
620 KB |
n=747 |
22 |
Correct |
14 ms |
748 KB |
n=991 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
488 ms |
16976 KB |
Expected int32, but "500000000000000000" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
n=4 |
2 |
Correct |
1 ms |
364 KB |
n=3 |
3 |
Correct |
1 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Correct |
1 ms |
364 KB |
n=8 |
9 |
Correct |
6 ms |
492 KB |
n=14 |
10 |
Correct |
4 ms |
364 KB |
n=11 |
11 |
Correct |
32 ms |
1764 KB |
n=50000 |
12 |
Correct |
31 ms |
1644 KB |
n=50000 |
13 |
Correct |
18 ms |
748 KB |
n=10 |
14 |
Correct |
20 ms |
876 KB |
n=685 |
15 |
Correct |
22 ms |
876 KB |
n=623 |
16 |
Correct |
13 ms |
620 KB |
n=973 |
17 |
Correct |
20 ms |
876 KB |
n=989 |
18 |
Correct |
10 ms |
620 KB |
n=563 |
19 |
Correct |
16 ms |
748 KB |
n=592 |
20 |
Correct |
17 ms |
748 KB |
n=938 |
21 |
Correct |
13 ms |
620 KB |
n=747 |
22 |
Correct |
14 ms |
748 KB |
n=991 |
23 |
Incorrect |
488 ms |
16976 KB |
Expected int32, but "500000000000000000" found |
24 |
Halted |
0 ms |
0 KB |
- |