# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
168920 | 2019-12-17T06:19:02 Z | abil | Gift (IZhO18_nicegift) | C++14 | 684 ms | 51160 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("%d%d", &n, &k); for(int i = 1;i <= n; i++){ scanf("%d", &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.rbegin(); s.erase(--s.end()); vec.pb({1, {x.sc, y.sc}}); if(y.fr - 1 > 0){ s.insert({y.fr - 1, y.sc}); } if(x.fr - 1 > 0){ s.insert({x.fr - 1, x.sc}); } } cout << vec.size() << endl; for(auto to : vec){ printf("%d %d %d\n",to.fr, to.sc.fr, to.sc.sc); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | n=4 |
2 | Correct | 2 ms | 376 KB | n=3 |
3 | Correct | 2 ms | 376 KB | n=3 |
4 | Correct | 2 ms | 380 KB | n=4 |
5 | Correct | 2 ms | 256 KB | n=4 |
6 | Correct | 2 ms | 256 KB | n=2 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | n=4 |
2 | Correct | 2 ms | 376 KB | n=3 |
3 | Correct | 2 ms | 376 KB | n=3 |
4 | Correct | 2 ms | 380 KB | n=4 |
5 | Correct | 2 ms | 256 KB | n=4 |
6 | Correct | 2 ms | 256 KB | n=2 |
7 | Correct | 2 ms | 376 KB | n=5 |
8 | Runtime error | 4 ms | 952 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | n=4 |
2 | Correct | 2 ms | 376 KB | n=3 |
3 | Correct | 2 ms | 376 KB | n=3 |
4 | Correct | 2 ms | 380 KB | n=4 |
5 | Correct | 2 ms | 256 KB | n=4 |
6 | Correct | 2 ms | 256 KB | n=2 |
7 | Correct | 2 ms | 376 KB | n=5 |
8 | Runtime error | 4 ms | 952 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 684 ms | 51160 KB | Not all heaps are empty in the end |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | n=4 |
2 | Correct | 2 ms | 376 KB | n=3 |
3 | Correct | 2 ms | 376 KB | n=3 |
4 | Correct | 2 ms | 380 KB | n=4 |
5 | Correct | 2 ms | 256 KB | n=4 |
6 | Correct | 2 ms | 256 KB | n=2 |
7 | Correct | 2 ms | 376 KB | n=5 |
8 | Runtime error | 4 ms | 952 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
9 | Halted | 0 ms | 0 KB | - |