제출 #1123695

#제출 시각아이디문제언어결과실행 시간메모리
1123695ezzzayPalembang Bridges (APIO15_bridge)C++20
22 / 100
88 ms2492 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define pb push_back const int N=3e5+5; int dist(int a, int b){ return abs(a-b); } signed main(){ int k,n; cin>>k>>n; int s=0; vector<int>vc; for(int i=1;i<=n;i++){ char x,y; int a,b; cin>>x>>a>>y>>b; if(x==y){ s+=abs(a-b); } else{ s++; vc.pb(a); vc.pb(b); } } sort(vc.begin(),vc.end()); for(int a:vc){ s+=dist(vc[(vc.size()/2)],a); } cout<<s; }
#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...