# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
97387 | Bruteforceman | Coin Collecting (JOI19_ho_t4) | C++11 | 118 ms | 4068 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
int x[200010], y[200010];
int cnt[3][100010];
vector <int> ball[3], cell[3];
int main(int argc, char const *argv[])
{
int n;
scanf("%d", &n);
long long ans = 0;
for(int i = 1; i <= n+n; i++) {
scanf("%d %d", &x[i], &y[i]);
if(y[i] <= 1) {
ans += abs(y[i] - 1);
y[i] = 1;
} else {
ans += abs(y[i] - 2);
y[i] = 2;
}
if(x[i] <= 1) {
ans += abs(x[i] - 1);
x[i] = 1;
} else if (x[i] > n) {
ans += abs(x[i] - n);
x[i] = n;
}
cnt[y[i]][x[i]] += 1;
}
for(int i = 1; i <= n; i++) {
cell[1].push_back(i);
cell[2].push_back(i);
for(int j = 1; j <= 2; j++) {
int p = cnt[j][i];
while(p--) {
ball[j].push_back(i);
}
}
for(int j = 1; j <= 2; j++) {
while(!cell[j].empty() && !ball[j].empty()) {
int p = cell[j].back();
int q = ball[j].back();
ans += abs(p - q);
cell[j].pop_back();
ball[j].pop_back();
}
}
for(int j = 1; j <= 2; j++) {
while(!cell[3 - j].empty() && !ball[j].empty()) {
int p = cell[3 - j].back();
int q = ball[j].back();
ans += abs(p - q) + 1;
cell[3 - j].pop_back();
ball[j].pop_back();
}
}
}
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... |