제출 #720764

#제출 시각아이디문제언어결과실행 시간메모리
720764mseebacherPalembang Bridges (APIO15_bridge)C++17
0 / 100
2 ms340 KiB
#include <bits/stdc++.h> using namespace std; // Idee 1 -> Set mit Wert|Index pair // Idee 2 -> SegTree damit void solve(){ int k; cin >> k; int n; cin >> n; vector<int> diff; long long sum = 0; for(int i = 0;i<n;i++){ char t1,t2; int c1,c2; cin >> t1 >> c1 >> t2 >> c2; if(t1 == t2){ sum += abs(c2-c1); }else{ diff.push_back(c1); diff.push_back(c2); } } sort(diff.begin(),diff.end()); sum += (diff.size() >> 1); int mid = (diff[diff.size()/2]+diff[(diff.size()-1)/2]) >> 1; for(int i = 0;i<(int)diff.size();i++){ sum += abs(diff[i]-mid); } cout << sum << " "; } int main(){ ios::sync_with_stdio(0); cin.tie(nullptr); cout << fixed << setprecision(8); solve(); }
#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...