# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
93277 | 2019-01-07T11:56:35 Z | SamAnd | Gift (IZhO18_nicegift) | C++17 | 505 ms | 63856 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); 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("%d ", 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 | 252 KB | n=4 |
2 | Correct | 2 ms | 256 KB | n=3 |
3 | Correct | 2 ms | 376 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 256 KB | n=4 |
6 | Correct | 2 ms | 348 KB | n=2 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 252 KB | n=4 |
2 | Correct | 2 ms | 256 KB | n=3 |
3 | Correct | 2 ms | 376 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 256 KB | n=4 |
6 | Correct | 2 ms | 348 KB | n=2 |
7 | Correct | 2 ms | 376 KB | n=5 |
8 | Correct | 1 ms | 376 KB | n=8 |
9 | Incorrect | 2 ms | 252 KB | Jury has the answer but participant has not |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 252 KB | n=4 |
2 | Correct | 2 ms | 256 KB | n=3 |
3 | Correct | 2 ms | 376 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 256 KB | n=4 |
6 | Correct | 2 ms | 348 KB | n=2 |
7 | Correct | 2 ms | 376 KB | n=5 |
8 | Correct | 1 ms | 376 KB | n=8 |
9 | Incorrect | 2 ms | 252 KB | Jury has the answer but participant has not |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 505 ms | 63856 KB | Added number should be positive |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 252 KB | n=4 |
2 | Correct | 2 ms | 256 KB | n=3 |
3 | Correct | 2 ms | 376 KB | n=3 |
4 | Correct | 2 ms | 376 KB | n=4 |
5 | Correct | 2 ms | 256 KB | n=4 |
6 | Correct | 2 ms | 348 KB | n=2 |
7 | Correct | 2 ms | 376 KB | n=5 |
8 | Correct | 1 ms | 376 KB | n=8 |
9 | Incorrect | 2 ms | 252 KB | Jury has the answer but participant has not |
10 | Halted | 0 ms | 0 KB | - |