This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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";
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |