# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
367408 | nicolaalexandra | Gift (IZhO18_nicegift) | C++14 | 551 ms | 70956 KiB |
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 <bits/stdc++.h>
#define DIM 1000010
using namespace std;
set <pair<int,int> > s;
vector <pair<int,int> > w;
vector <int> sol[DIM];
int v[DIM];
int n,k,i,el;
int main (){
//ifstream cin ("date.in");
//ofstream cout ("date.out");
cin>>n>>k;
for (i=1;i<=n;i++){
cin>>v[i];
s.insert(make_pair(v[i],i));
}
while (!s.empty()){
if (s.size() < k){
cout<<-1;
return 0;
}
int val = s.begin()->first;
sol[++el].push_back (val);
int pas = 0;
w.clear();
for (auto it : s){
w.push_back(it);
sol[el].push_back(it.second);
pas++;
if (pas == k)
break;
}
for (auto it : w){
int x = it.first, poz = it.second;
s.erase(make_pair(x,poz));
if (x > val)
s.insert(make_pair(x-val,poz));
}
}
cout<<el<<"\n";
for (i=1;i<=el;i++){
for (auto it : sol[i])
cout<<it<<" ";
cout<<"\n";
}
return 0;
}
Compilation message (stderr)
# | 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... |