# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
65183 | 2018-08-07T00:50:15 Z | kingpig9 | Gift (IZhO18_nicegift) | C++11 | 399 ms | 23348 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 2e6 + 10; #define debug(...) fprintf(stderr, __VA_ARGS__) #define all(v) (v).begin(), (v).end() #define fi first #define se second #define fillchar(a, s) memset((a), (s), sizeof(a)) void kill() { puts("-1"); exit(0); } int N, K; ll A[MAXN], suma; namespace subtask3 { void go() { printf("%lld\n", suma / K); priority_queue<pll> pq; for (int i = 0; i < N; i++) { pq.push(pll(A[i], i)); } while (!pq.empty()) { vector<pll> vnew; printf("1"); for (int i = 0; i < K; i++) { if (pq.empty()) kill(); pll p = pq.top(); pq.pop(); if (--p.fi) { vnew.push_back(p); } printf(" %lld", p.se + 1); } puts(""); for (pll p : vnew) { pq.push(p); } } } } namespace subtask4 { void go() { ll g = __gcd(N, K); ll v = A[0] * g / K; ll nturns = N / g; printf("%lld\n", nturns); int ptr = 0; for (ll i = 0; i < nturns; i++) { printf("%lld", v); for (int j = 0; j < K; j++) { printf(" %d", ptr + 1); ptr = (ptr + 1) % N; } puts(""); } } } int main() { scanf("%d %d", &N, &K); for (int i = 0; i < N; i++) { scanf("%lld", &A[i]); suma += A[i]; } if (suma % K != 0) { kill(); } if (suma <= 1e5) { subtask3::go(); } else { subtask4::go(); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 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 | 576 KB | n=4 |
5 | Correct | 2 ms | 644 KB | n=4 |
6 | Correct | 4 ms | 644 KB | n=2 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 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 | 576 KB | n=4 |
5 | Correct | 2 ms | 644 KB | n=4 |
6 | Correct | 4 ms | 644 KB | n=2 |
7 | Correct | 3 ms | 644 KB | n=5 |
8 | Incorrect | 8 ms | 644 KB | Expected integer, but "6-1" found |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 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 | 576 KB | n=4 |
5 | Correct | 2 ms | 644 KB | n=4 |
6 | Correct | 4 ms | 644 KB | n=2 |
7 | Correct | 3 ms | 644 KB | n=5 |
8 | Incorrect | 8 ms | 644 KB | Expected integer, but "6-1" found |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 399 ms | 23348 KB | n=1000000 |
2 | Correct | 252 ms | 23348 KB | n=666666 |
3 | Correct | 130 ms | 23348 KB | n=400000 |
4 | Correct | 374 ms | 23348 KB | n=285714 |
5 | Correct | 12 ms | 23348 KB | n=20000 |
6 | Correct | 271 ms | 23348 KB | n=181818 |
7 | Correct | 10 ms | 23348 KB | n=10000 |
8 | Correct | 47 ms | 23348 KB | n=6666 |
9 | Correct | 5 ms | 23348 KB | n=4000 |
10 | Correct | 227 ms | 23348 KB | n=2857 |
11 | Correct | 5 ms | 23348 KB | n=2000 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 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 | 576 KB | n=4 |
5 | Correct | 2 ms | 644 KB | n=4 |
6 | Correct | 4 ms | 644 KB | n=2 |
7 | Correct | 3 ms | 644 KB | n=5 |
8 | Incorrect | 8 ms | 644 KB | Expected integer, but "6-1" found |
9 | Halted | 0 ms | 0 KB | - |