# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1034577 | juicy | Coin Collecting (JOI19_ho_t4) | C++17 | 37 ms | 4944 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
const int N = 1e5 + 5;
int n;
int cnt[N][2];
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n;
long long res = 0;
for (int i = 0; i < 2 * n; ++i) {
int x, y; cin >> x >> y;
if (x > n) {
res += x - n;
x = n;
} else if (x < 1) {
res += 1 - x;
x = 1;
}
if (y < 2) {
res += 1 - y;
y = 1;
} else {
res += y - 2;
y = 2;
}
assert(1 <= x && x <= n && 1 <= y && y <= 2);
++cnt[x][y];
}
int a = 0, b = 0;
for (int i = 1; i <= n; ++i) {
a += cnt[i][1] - 1, b += cnt[i][2] - 1;
while (a > 0 && b < 0) {
a--, b++, res++;
}
while (a < 0 && b > 0) {
a++, b--, res++;
}
res += abs(a) + abs(b);
}
cout << res;
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... |