Submission #776817

#TimeUsernameProblemLanguageResultExecution timeMemory
776817khoquennguoiminhthuongPalembang Bridges (APIO15_bridge)C++14
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; int n,k; long long ans=0; int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>k>>n; vector<pair<int,int>>vec; vector<int>pos; for(int i=1;i<=n;i++) { char a,b;int x,y; cin>>a>>x>>b>>y; if(a==b)ans+=abs(x-y); else {vec.push_back({x,y});pos.push_back(x);pos.push_back(y);} } ans+=vec.size(); sort(pos.begin(),pos.end()); int vv=pos.size(); int vvv=pos[vv/2]; for(auto v:vec)ans+=abs(v.first-vvv)+abs(v.second-vvv); cout<<ans; return 0;; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...