#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> pii;
int N,K,M;
pii A[1000006];
vector<int> V[3000006];
int main(){
cin>>N>>K;
for(int i=0;i<N;i++){
cin>>A[i].first;
A[i].second=i+1;
}
sort(A,A+N,greater<pii>());
while(A[0].first and (M+1)*K<=3000000){
V[M].push_back(A[K-1].first);
for(int i=0;i<K;i++){
A[i].first-=A[K-1].first;
V[M].push_back(A[i].second);
}
sort(A,A+N,greater<pii>());
M++;
}
if(A[0].first)
cout<<-1;
else{
cout<<M<<"\n";
for(int i=0;i<M;i++){
for(int x:V[i])
cout<<x<<" ";
cout<<"\n";
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
66 ms |
70776 KB |
n=4 |
2 |
Correct |
67 ms |
70776 KB |
n=3 |
3 |
Correct |
333 ms |
117808 KB |
n=3 |
4 |
Correct |
67 ms |
70776 KB |
n=4 |
5 |
Correct |
336 ms |
117668 KB |
n=4 |
6 |
Correct |
328 ms |
117752 KB |
n=2 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
66 ms |
70776 KB |
n=4 |
2 |
Correct |
67 ms |
70776 KB |
n=3 |
3 |
Correct |
333 ms |
117808 KB |
n=3 |
4 |
Correct |
67 ms |
70776 KB |
n=4 |
5 |
Correct |
336 ms |
117668 KB |
n=4 |
6 |
Correct |
328 ms |
117752 KB |
n=2 |
7 |
Correct |
82 ms |
70776 KB |
n=5 |
8 |
Correct |
351 ms |
117880 KB |
n=8 |
9 |
Incorrect |
387 ms |
117804 KB |
Jury has the answer but participant has not |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
66 ms |
70776 KB |
n=4 |
2 |
Correct |
67 ms |
70776 KB |
n=3 |
3 |
Correct |
333 ms |
117808 KB |
n=3 |
4 |
Correct |
67 ms |
70776 KB |
n=4 |
5 |
Correct |
336 ms |
117668 KB |
n=4 |
6 |
Correct |
328 ms |
117752 KB |
n=2 |
7 |
Correct |
82 ms |
70776 KB |
n=5 |
8 |
Correct |
351 ms |
117880 KB |
n=8 |
9 |
Incorrect |
387 ms |
117804 KB |
Jury has the answer but participant has not |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2055 ms |
78652 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
66 ms |
70776 KB |
n=4 |
2 |
Correct |
67 ms |
70776 KB |
n=3 |
3 |
Correct |
333 ms |
117808 KB |
n=3 |
4 |
Correct |
67 ms |
70776 KB |
n=4 |
5 |
Correct |
336 ms |
117668 KB |
n=4 |
6 |
Correct |
328 ms |
117752 KB |
n=2 |
7 |
Correct |
82 ms |
70776 KB |
n=5 |
8 |
Correct |
351 ms |
117880 KB |
n=8 |
9 |
Incorrect |
387 ms |
117804 KB |
Jury has the answer but participant has not |
10 |
Halted |
0 ms |
0 KB |
- |