# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
43379 | top34051 | Palembang Bridges (APIO15_bridge) | C++14 | 2 ms | 724 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 n,k;
vector<int> pos;
int main() {
long long ans = 0;
scanf("%d%d",&k,&n);
for(int i=1;i<=n;i++) {
int x, y;
char t1, t2;
scanf(" %c%d %c%d",&t1,&x,&t2,&y);
if(t1==t2) ans += abs(y-x);
else {
pos.push_back(x);
pos.push_back(y);
ans++;
}
}
sort(pos.begin(),pos.end());
int opt = pos[pos.size()/2];
// printf("opt %d\n",opt);
for(auto x : pos) ans += abs(opt-x);
printf("%lld",ans);
}
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... |