# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
138852 | KCSC | Hokej (COCI17_hokej) | C++14 | 545 ms | 22976 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int DIM = 500005;
struct Player {
int x, y, id;
} arr[DIM];
vector<pair<int, int>> chn[DIM];
vector<int> fst;
inline bool cmp(Player p1, Player p2) {
if (p1.x == p2.x)
return p1.y < p2.y;
return p1.x > p2.x;
}
int main(void) {
#ifdef HOME
freopen("hokej.in", "r", stdin);
freopen("hokej.out", "w", stdout);
#endif
int m, n;
cin >> m >> n;
for (int i = 1; i <= n; ++i) {
int x, y;
cin >> x >> y;
arr[i] = {x, y, i};
}
sort(arr + 1, arr + n + 1, cmp);
int cnt = 0, t = m;
long long ans = 0;
for (int i = 1, b = 0, tp = 0, lst = 0; i <= n and b < 6; ) {
int s = arr[i].x, e = arr[i].y, id = arr[i].id;
if (e == 0) {
++i;
continue;
}
t = min(e, m - tp);
if (tp == 0 and fst.size() < 6)
fst.push_back(id);
else if (b != 5 and e == m) {
++b; ++i;
ans += 1LL * m * s;
fst.push_back(id);
continue; // no more updates here
} else {
++cnt;
chn[tp].push_back(make_pair(lst, id));
}
tp += t;
ans += 1LL * t * s;
arr[i].y -= t; lst = id;
lst = id;
if (tp == m) {
++b;
tp = 0;
}
}
cout << ans << "\n";
for (int i = 0; i < 6; ++i)
cout << fst[i] << " ";
cout << "\n" << cnt << "\n";
for (int i = 0; i < m; ++i) {
reverse(chn[i].begin(), chn[i].end());
for (int j = 0; j < chn[i].size(); ++j)
cout << i << " " << chn[i][j].first << " " << chn[i][j].second << "\n";
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |