| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 229743 | PeppaPig | Coin Collecting (JOI19_ho_t4) | C++14 | 79 ms | 6648 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define long long long
using namespace std;
const int N = 1e5+5;
int n, cnt[3][N];
long ans;
queue<int> pos[3], coin[3];
int main() {
scanf("%d", &n);
for(int i = 1, x, y; i <= 2 * n; i++) {
scanf("%d %d", &x, &y);
if(x < 1) ans += abs(x - 1), x = 1;
if(x > n) ans += abs(x - n), x = n;
if(y < 1) ans += abs(y - 1), y = 1;
if(y > 2) ans += abs(y - 2), y = 2;
++cnt[y][x];
}
for(int i = 1; i <= n; i++) {
pos[1].emplace(i), pos[2].emplace(i);
for(int j = 1; j <= 2; j++)
while(cnt[j][i]--) coin[j].emplace(i);
for(int j = 1; j <= 2; j++) while(!pos[j].empty() && !coin[j].empty()) {
ans += abs(pos[j].front() - coin[j].front());
pos[j].pop(), coin[j].pop();
}
for(int j = 1; j <= 2; j++) while(!pos[j ^ 3].empty() && !coin[j].empty()) {
ans += abs(pos[j ^ 3].front() - coin[j].front()) + 1;
pos[j ^ 3].pop(), coin[j].pop();
}
}
printf("%lld\n", ans);
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... | ||||
