# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
111340 | ppnxblstr | Palembang Bridges (APIO15_bridge) | C++14 | 57 ms | 1648 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;
char p[2];
char q[2];
int main(){
int k, n;
scanf("%d%d",&k,&n);
vector<int> v;
int s, t;
long long d = 0ll;
for(int i = 1; i <= n; i++){
scanf("%s%d%s%d",p,&s,q,&t);
if(p[0] == q[0]){
d += (long long)abs(s-t);
}else{
v.push_back(s);
v.push_back(t);
}
}
sort(v.begin(), v.end());
if(k == 1){
int x = v[(v.size()-1)/2];
for(int i : v){
d += (long long)abs(i-x);
}
printf("%lld\n",d + v.size()/2);
return 0;
}
}
/*
1 5
B 0 A 4
B 1 B 3
A 5 B 7
B 2 A 6
B 1 A 7
*/
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... |