제출 #979628

#제출 시각아이디문제언어결과실행 시간메모리
979628tamir1Palembang Bridges (APIO15_bridge)C++17
22 / 100
30 ms4188 KiB
#include<bits/stdc++.h> #define ll long long using namespace std; ll ans,n,k,i,x,y,l,a[200005]; char s,t; int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> k >> n; for(i=1;i<=n;i++){ cin >> s >> x >> t >> y; if(s==t) ans+=abs(x-y); else{ ans++; l++; a[l]=x; l++; a[l]=y; } } sort(a+1,a+l+1); x=a[(l+1)/2]; //cout << x << " "; for(i=1;i<=l;i++){ ans+=abs(x-a[i]); } cout << ans; }
#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...