# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
80730 | 2018-10-22T05:10:43 Z | inom | Gift (IZhO18_nicegift) | C++14 | 2000 ms | 171152 KB |
#include <iostream> #include <vector> #include <algorithm> #include <set> using namespace std; #define ll long long #define mp make_pair const int MAXN = 1e6; pair <int, int> a[MAXN]; vector< vector< ll > > ans; int main() { int n, k; scanf("%d%d", &n, &k); set < pair <ll, int> > S; for (int i = 0; i < n; i++) { scanf("%d", &a[i].first); a[i].second = i + 1; S.insert(mp(-a[i].first, i + 1)); } vector <ll> res; res.resize(3); while (!S.empty()) { if (S.size() == 1) { printf("-1"); return 0; } res[0] = 1; pair <ll, int> P = *S.begin(); S.erase(S.begin()); res[1] = P.second; pair <ll, int> P2 = *S.begin(); S.erase(S.begin()); res[2] = P2.second; if (P.first != -1ll) { S.insert(mp(P.first + 1, P.second)); } if (P2.first != -1ll) { S.insert(mp(P2.first + 1, P2.second)); } ans.push_back(res); } if (!S.empty()) { printf("-1"); return 0; } printf("%d\n", (int)ans.size()); for (int i = 0; i < ans.size(); i++) { for (int j = 0; j <= k; j++) { printf("%lld ", ans[i][j]); } printf("\n"); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | n=4 |
2 | Correct | 2 ms | 372 KB | n=3 |
3 | Correct | 2 ms | 408 KB | n=3 |
4 | Correct | 2 ms | 484 KB | n=4 |
5 | Correct | 2 ms | 544 KB | n=4 |
6 | Correct | 2 ms | 556 KB | n=2 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | n=4 |
2 | Correct | 2 ms | 372 KB | n=3 |
3 | Correct | 2 ms | 408 KB | n=3 |
4 | Correct | 2 ms | 484 KB | n=4 |
5 | Correct | 2 ms | 544 KB | n=4 |
6 | Correct | 2 ms | 556 KB | n=2 |
7 | Correct | 2 ms | 560 KB | n=5 |
8 | Correct | 6 ms | 1260 KB | n=8 |
9 | Correct | 10 ms | 1448 KB | n=14 |
10 | Correct | 7 ms | 1448 KB | n=11 |
11 | Correct | 46 ms | 6576 KB | n=50000 |
12 | Correct | 49 ms | 6828 KB | n=50000 |
13 | Correct | 38 ms | 6828 KB | n=10 |
14 | Correct | 31 ms | 6828 KB | n=685 |
15 | Correct | 32 ms | 6828 KB | n=623 |
16 | Correct | 19 ms | 6828 KB | n=973 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | n=4 |
2 | Correct | 2 ms | 372 KB | n=3 |
3 | Correct | 2 ms | 408 KB | n=3 |
4 | Correct | 2 ms | 484 KB | n=4 |
5 | Correct | 2 ms | 544 KB | n=4 |
6 | Correct | 2 ms | 556 KB | n=2 |
7 | Correct | 2 ms | 560 KB | n=5 |
8 | Correct | 6 ms | 1260 KB | n=8 |
9 | Correct | 10 ms | 1448 KB | n=14 |
10 | Correct | 7 ms | 1448 KB | n=11 |
11 | Correct | 46 ms | 6576 KB | n=50000 |
12 | Correct | 49 ms | 6828 KB | n=50000 |
13 | Correct | 38 ms | 6828 KB | n=10 |
14 | Correct | 31 ms | 6828 KB | n=685 |
15 | Correct | 32 ms | 6828 KB | n=623 |
16 | Correct | 19 ms | 6828 KB | n=973 |
17 | Incorrect | 41 ms | 6828 KB | Integer 0 violates the range [1, 989] |
18 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2068 ms | 171152 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | n=4 |
2 | Correct | 2 ms | 372 KB | n=3 |
3 | Correct | 2 ms | 408 KB | n=3 |
4 | Correct | 2 ms | 484 KB | n=4 |
5 | Correct | 2 ms | 544 KB | n=4 |
6 | Correct | 2 ms | 556 KB | n=2 |
7 | Correct | 2 ms | 560 KB | n=5 |
8 | Correct | 6 ms | 1260 KB | n=8 |
9 | Correct | 10 ms | 1448 KB | n=14 |
10 | Correct | 7 ms | 1448 KB | n=11 |
11 | Correct | 46 ms | 6576 KB | n=50000 |
12 | Correct | 49 ms | 6828 KB | n=50000 |
13 | Correct | 38 ms | 6828 KB | n=10 |
14 | Correct | 31 ms | 6828 KB | n=685 |
15 | Correct | 32 ms | 6828 KB | n=623 |
16 | Correct | 19 ms | 6828 KB | n=973 |
17 | Incorrect | 41 ms | 6828 KB | Integer 0 violates the range [1, 989] |
18 | Halted | 0 ms | 0 KB | - |