# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
56557 | leejseo | Palembang Bridges (APIO15_bridge) | C++98 | 92 ms | 20040 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int K, N;
long long ans = 0;
vector<int> L;
int main(void){
int u, v;
char x, y;
scanf("%d%d\n", &K, &N);
for(int i=0; i<N; i++){
scanf("%c %d %c %d\n", &x, &u, &y, &v);
if (x == y) ans += abs(u-v);
else{
L.push_back(u);
L.push_back(v);
}
}
sort(L.begin(), L.end());
int M = L.size();
if (M == 0){
printf("%lld\n", ans);
return 0;
}
long long mid = L[M/2];
for (int i=0; i<M; i++) ans += abs(L[i] - mid);
ans += M/2;
printf("%lld\n", ans);
return 0;
}
Compilation message (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... |