제출 #720738

#제출 시각아이디문제언어결과실행 시간메모리
720738mseebacherPalembang Bridges (APIO15_bridge)C++17
0 / 100
3 ms356 KiB
#include <bits/stdc++.h> using namespace std; // Idee 1 -> Set mit Wert|Index pair // Idee 2 -> SegTree damit struct Platz{ char type; int c; }; void solve(){ int k; cin >> k; int n; cin >> n; vector<Platz> home(n); vector<Platz> arbeit(n); for(int i = 0;i<n;i++){ cin >> home[i].type >> home[i].c >> arbeit[i].type >> arbeit[i].c; } long long ans = 1e9; for(int i = 0;i<n;i++){ long long sum = 0; for(int j = 0;j<n;j++){ if(home[j].type == arbeit[j].type){ sum += abs(home[j].c-arbeit[j].c); }else{ sum += abs(home[j].c-home[i].c) + abs(arbeit[j].c - home[i].c)+1; } } ans = min(ans,sum); } cout << ans; } 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...