# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
367408 | 2021-02-17T08:19:39 Z | nicolaalexandra | Gift (IZhO18_nicegift) | C++14 | 551 ms | 70956 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 23788 KB | n=4 |
2 | Incorrect | 14 ms | 23788 KB | Jury has the answer but participant has not |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 23788 KB | n=4 |
2 | Incorrect | 14 ms | 23788 KB | Jury has the answer but participant has not |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 23788 KB | n=4 |
2 | Incorrect | 14 ms | 23788 KB | Jury has the answer but participant has not |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 551 ms | 70956 KB | Jury has the answer but participant has not |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 23788 KB | n=4 |
2 | Incorrect | 14 ms | 23788 KB | Jury has the answer but participant has not |
3 | Halted | 0 ms | 0 KB | - |