제출 #585520

#제출 시각아이디문제언어결과실행 시간메모리
585520karriganPalembang Bridges (APIO15_bridge)C++14
22 / 100
45 ms4368 KiB
#include<bits/stdc++.h> #define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr); using namespace std; struct line{ char x,z; long long y,t; }a[100009]; vector<long long>b; long long pf[200009]; int main() { fastio int k,n; cin>>k>>n; long long ans=0; for (int i=1;i<=n;i++){ cin>>a[i].x>>a[i].y>>a[i].z>>a[i].t; if (a[i].x!=a[i].z){ b.push_back(a[i].y); b.push_back(a[i].t); ans++; } else { ans+=abs(a[i].y-a[i].t); } } if (k==1){ sort(b.begin(),b.end()); int d=(int)b.size(); d/=2; for (int i=0;i<(int)b.size();i++){ if (b[i]<=b[d]){ ans=ans+b[d]-b[i]; } else ans=ans+b[i]-b[d]; } 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...