# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
93284 | 2019-01-07T12:03:57 Z | SamAnd | Gift (IZhO18_nicegift) | C++17 | 2000 ms | 352292 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1000006; struct ban { int i; long long x; ban(){} ban(int i, long long x) { this->i = i; this->x = x; } }; bool operator<(const ban& a, const ban& b) { return a.x < b.x; } int n, k; long long a[N]; void solv1() { vector<vector<long long> > ans; priority_queue<ban> q; for (int i = 1; i <= n; ++i) q.push(ban(i, a[i])); bool z = false; while (1) { if (q.size() == 0) { z = true; break; } if (q.size() < k) break; vector<ban> v; for (int ii = 0; ii < k; ++ii) { v.push_back(q.top()); q.pop(); } long long minu = v[0].x; for (int i = 1; i < k; ++i) minu = min(minu, v[i].x); minu = 1; vector<long long> vv; vv.push_back(minu); for (int i = 0; i < k; ++i) { v[i].x -= minu; if (v[i].x) q.push(v[i]); vv.push_back(v[i].i); } ans.push_back(vv); } if (!z) { printf("-1\n"); return; } printf("%d\n", ans.size()); for (int i = 0; i < ans.size(); ++i) { for (int j = 0; j < ans[i].size(); ++j) printf("%lld ", ans[i][j]); printf("\n"); } } int main() { //freopen("input2.txt", "r", stdin); scanf("%d%d", &n, &k); for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]); solv1(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | n=4 |
2 | Correct | 2 ms | 256 KB | n=3 |
3 | Correct | 2 ms | 256 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 376 KB | n=4 |
6 | Correct | 2 ms | 376 KB | n=2 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | n=4 |
2 | Correct | 2 ms | 256 KB | n=3 |
3 | Correct | 2 ms | 256 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 376 KB | n=4 |
6 | Correct | 2 ms | 376 KB | n=2 |
7 | Correct | 2 ms | 256 KB | n=5 |
8 | Correct | 5 ms | 1016 KB | n=8 |
9 | Correct | 9 ms | 1200 KB | n=14 |
10 | Correct | 6 ms | 1016 KB | n=11 |
11 | Correct | 38 ms | 5088 KB | n=50000 |
12 | Correct | 37 ms | 5120 KB | n=50000 |
13 | Correct | 32 ms | 3512 KB | n=10 |
14 | Correct | 29 ms | 3072 KB | n=685 |
15 | Correct | 31 ms | 3372 KB | n=623 |
16 | Correct | 18 ms | 2092 KB | n=973 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | n=4 |
2 | Correct | 2 ms | 256 KB | n=3 |
3 | Correct | 2 ms | 256 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 376 KB | n=4 |
6 | Correct | 2 ms | 376 KB | n=2 |
7 | Correct | 2 ms | 256 KB | n=5 |
8 | Correct | 5 ms | 1016 KB | n=8 |
9 | Correct | 9 ms | 1200 KB | n=14 |
10 | Correct | 6 ms | 1016 KB | n=11 |
11 | Correct | 38 ms | 5088 KB | n=50000 |
12 | Correct | 37 ms | 5120 KB | n=50000 |
13 | Correct | 32 ms | 3512 KB | n=10 |
14 | Correct | 29 ms | 3072 KB | n=685 |
15 | Correct | 31 ms | 3372 KB | n=623 |
16 | Correct | 18 ms | 2092 KB | n=973 |
17 | Correct | 28 ms | 3068 KB | n=989 |
18 | Correct | 14 ms | 1272 KB | n=563 |
19 | Correct | 20 ms | 1784 KB | n=592 |
20 | Correct | 20 ms | 1784 KB | n=938 |
21 | Correct | 16 ms | 1400 KB | n=747 |
22 | Correct | 18 ms | 1656 KB | n=991 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2054 ms | 352292 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | n=4 |
2 | Correct | 2 ms | 256 KB | n=3 |
3 | Correct | 2 ms | 256 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 376 KB | n=4 |
6 | Correct | 2 ms | 376 KB | n=2 |
7 | Correct | 2 ms | 256 KB | n=5 |
8 | Correct | 5 ms | 1016 KB | n=8 |
9 | Correct | 9 ms | 1200 KB | n=14 |
10 | Correct | 6 ms | 1016 KB | n=11 |
11 | Correct | 38 ms | 5088 KB | n=50000 |
12 | Correct | 37 ms | 5120 KB | n=50000 |
13 | Correct | 32 ms | 3512 KB | n=10 |
14 | Correct | 29 ms | 3072 KB | n=685 |
15 | Correct | 31 ms | 3372 KB | n=623 |
16 | Correct | 18 ms | 2092 KB | n=973 |
17 | Correct | 28 ms | 3068 KB | n=989 |
18 | Correct | 14 ms | 1272 KB | n=563 |
19 | Correct | 20 ms | 1784 KB | n=592 |
20 | Correct | 20 ms | 1784 KB | n=938 |
21 | Correct | 16 ms | 1400 KB | n=747 |
22 | Correct | 18 ms | 1656 KB | n=991 |
23 | Execution timed out | 2054 ms | 352292 KB | Time limit exceeded |
24 | Halted | 0 ms | 0 KB | - |