| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 813542 | Charizard2021 | Coin Collecting (JOI19_ho_t4) | C++17 | 1 ms | 212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 200001;
int dp[2][N];
int main(){
int n;
cin >> n;
int ans = 0;
for(int i = 0; i < 2 * n; i++){
int x, y;
cin >> x >> y;
if(x < 1){
ans += 1 - x;
x = 1;
}
if(x > n){
ans += x - n;
x = n;
}
if(y < 1){
ans += 1 - y;
y = 1;
}
if(y > 2){
ans += y - 2;
y = 2;
}
dp[y - 1][x]++;
}
for(int i = 1; i <= n; i++){
dp[0][i] -= 1;
dp[1][i] -= 1;
if(dp[0][i] * dp[1][i] < 0){
if(dp[0][i] < 0){
int x = min(abs(dp[0][i]), dp[1][i]);
dp[0][i] += x;
dp[1][i] -= x;
ans += x;
}
else{
int x = min(abs(dp[1][i]), dp[0][i]);
dp[0][i] -= x;
dp[1][i] += x;
ans += x;
}
}
ans += abs(dp[0][i]) + abs(dp[1][i]);
dp[0][i + 1] += dp[0][i];
dp[1][i + 1] += dp[1][i];
}
cout << ans << "\n";
}| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
