# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
168917 | 2019-12-17T06:12:40 Z | abil | Gift (IZhO18_nicegift) | C++14 | 2000 ms | 84716 KB |
#include <bits/stdc++.h> #define fr first #define sc second #define pb push_back #define mk make_pair #define all(s) s.begin(),s.end() #define int long long using namespace std; const int N = (1e6 + 12); const int mod = (1e9 + 7); const int INF = (0x3f3f3f3f); int a[N]; set<pair<int,int > > s; vector<pair<int,pair<int,int > > > vec; main() { int n, k, sum = 0; scanf("%lld%lld", &n, &k); for(int i = 1;i <= n; i++){ scanf("%lld", &a[i]); sum += a[i]; s.insert({a[i], i}); } if(sum % k != 0){ cout << -1; return 0; } while(!s.empty()){ pair<int,int > x, y; x = *s.begin(); s.erase(s.begin()); y = *s.begin(); s.erase(s.begin()); vec.pb({x.fr, {x.sc, y.sc}}); if(y.fr - x.fr > 0){ s.insert({y.fr - x.fr, y.sc}); } } cout << vec.size() << endl; for(auto to : vec){ cout << to.fr << " " << to.sc.fr << " " << to.sc.sc << endl; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | n=4 |
2 | Execution timed out | 2067 ms | 376 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | n=4 |
2 | Execution timed out | 2067 ms | 376 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | n=4 |
2 | Execution timed out | 2067 ms | 376 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2045 ms | 84716 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | n=4 |
2 | Execution timed out | 2067 ms | 376 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |