| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 80730 | inom | Gift (IZhO18_nicegift) | C++14 | 2068 ms | 171152 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
