# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1088447 | Sunbae | Palembang Bridges (APIO15_bridge) | C++17 | 35 ms | 4308 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int a[200000], P[100000][2];
bool ok[100000];
signed main(){
int k, n, m = 0; scanf("%d %d", &k, &n);
ll tot = 0, s[2] = {0, 0};
for(int i = 0; i<n; ++i){
char c[2]; int p[2]; scanf(" %c %d %c %d", c, p, c+1, p+1);
if(c[0] == c[1]) tot += abs(p[0]-p[1]);
else {a[m++] = p[0]; a[m++] = p[1]; ok[i] = true;}
P[i][0] = p[0]; P[i][1] = p[1];
}
sort(a, a+m);
if(k == 1){
for(int j = 0; j<2; ++j) for(int i = 0; i<m; ++i) s[j] += abs(a[i] - a[m/2 - j]);
printf("%lld", tot + min(s[0], s[1]) + m/2);
}else{
for(int i = 0; i<n; ++i){
if(ok[i]){
ll o[2] = {0, 0};
for(int j = 0; j<2; ++j) o[j] = (ll)abs(P[i][0] - a[m/2 - j]) + (ll)abs(P[i][1] - a[m/2 - j]);
tot += min(o[0], o[1]);
}
}
printf("%lld", tot + m/2);
}
}
컴파일 시 표준 에러 (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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |