# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
117916 | songc | Coin Collecting (JOI19_ho_t4) | C++14 | 73 ms | 2552 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1234567890
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
int N;
int A[2][101010];
LL ans;
int main(){
int x, y, k;
scanf("%d", &N);
for (int i=1; i<=2*N; i++){
scanf("%d %d", &x, &y);
if (y <= 1) ans += 1-y, y=1;
else ans += y-2, y=2;
if (x <= 1) ans += 1-x, x=1;
else if (x >= N) ans += x-N, x=N;
A[y-1][x]++;
}
for (int i=1; i<=N; i++){
if (A[0][i] < 1 && A[1][i] > 1){
k = min(1-A[0][i], A[1][i]-1);
ans += k, A[0][i] += k, A[1][i] -= k;
}
if (A[1][i] < 1 && A[0][i] > 1){
k = min(1-A[1][i], A[0][i]-1);
ans += k, A[1][i] += k, A[0][i] -= k;
}
A[0][i+1] += A[0][i]-1, ans += abs(A[0][i]-1);
A[1][i+1] += A[1][i]-1, ans += abs(A[1][i]-1);
}
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... |