| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 730434 | speedyArda | Coin Collecting (JOI19_ho_t4) | C++14 | 193 ms | 7320 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const int MAXN = 1e5+5;
ll cnt[MAXN][3];
int main()
{
int n;
cin >> n;
ll ans = 0;
for(int i = 1; i <= 2 * n; i++)
{
int x, y;
cin >> x >> y;
if(x <= 1) {
ans += 1 - x;
x = 1;
}
else if(x > n) {
ans += x - n;
x = n;
}
if(y <= 1) {
ans += 1 - y;
y = 1;
}
else {
ans += y - 2;
y = 2;
}
cnt[x][y]++;
}
ll up = 1, down = 1;
ll remup = 0, remdown = 0;
for(int pr=1; pr<=n ;pr++){
while(up<=pr && cnt[pr][1]>0) ans+=pr-up++,cnt[pr][1]--;
while(down<=pr && cnt[pr][2]>0) ans+=pr-down++,cnt[pr][2]--;
while(up>pr && down<=pr && cnt[pr][1]>0) ans+=pr+1-down++,cnt[pr][1]--;
while(down>pr && up<=pr && cnt[pr][2]>0) ans+=pr+1-up++,cnt[pr][2]--;
ans+=cnt[pr][1];cnt[pr+1][1]+=cnt[pr][1];cnt[pr][1]=0;
ans+=cnt[pr][2];cnt[pr+1][2]+=cnt[pr][2];cnt[pr][2]=0;
}
cout << ans << "\n";
}
컴파일 시 표준 에러 (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... | ||||
