# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
111334 | ppnxblstr | Palembang Bridges (APIO15_bridge) | C++14 | 2 ms | 384 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);
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... |