# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
146091 | str0ct | Palembang Bridges (APIO15_bridge) | C++14 | 2 ms | 376 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;
using ll=long long;
ll K,N;
vector <pair<ll,ll> > V;
ll D1,D2;
ll ans;
void sol2(){
vector <ll> ab;
for(auto p:V){
ab.push_back(p.first);
ab.push_back(p.second);
}
sort(ab.begin(),ab.end());
D1=ab[N-1];
for(auto p:ab){
ans+=abs(D1-p);
}
}
int main(){
scanf("%lld%lld",&K,&N);
for(ll i=0;i<N;i++){
char p,q;
ll s,t;
scanf(" %c%lld %c%lld",&p,&s,&q,&t);
if(p-'B')V.push_back({s,t});
else V.push_back({t,s});
}
if(K-2)sol2();
//else sol1();
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... |