제출 #497684

#제출 시각아이디문제언어결과실행 시간메모리
497684clamsPalembang Bridges (APIO15_bridge)C++17
0 / 100
1 ms460 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int k, n; cin >> k >> n; vector<pair<pair<char, long long>, pair<char, long long>>> a(n); vector<long long> pos; for (int i = 0; i < n; i++) { cin >> a[i].first.first >> a[i].first.second; cin >> a[i].second.first >> a[i].second.second; if (a[i].first.first != a[i].second.first) { pos.push_back(a[i].first.second); pos.push_back(a[i].second.second); } } sort(pos.begin(), pos.end()); int median = pos[(int)pos.size() / 2]; long long ans = 0; for (int i = 0; i < n; i++) { if (a[i].first.first != a[i].second.first) { ans += abs(median - a[i].first.second); ans += abs(median - a[i].second.second); ans += 1; } else { ans += abs(a[i].first.second - a[i].second.second); } } cout << ans; return 0; } /* 1 5 B 0 A 4 B 1 B 3 A 5 B 7 B 2 A 6 B 1 A 7 */
#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...