제출 #705200

#제출 시각아이디문제언어결과실행 시간메모리
705200bebraPalembang Bridges (APIO15_bridge)C++17
22 / 100
39 ms3536 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define dbg(x) cerr << #x << ": " << x << endl; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int k, n; cin >> k >> n; ll ans = 0; vector<int> coords; for (int i = 0; i < n; ++i) { char c1; cin >> c1; int x1; cin >> x1; char c2; cin >> c2; int x2; cin >> x2; if (c1 == c2) { ans += abs(x1 - x2); } else { coords.push_back(x1); coords.push_back(x2); ++ans; } } sort(coords.begin(), coords.end()); for (auto x : coords) { ans += abs(x - coords[coords.size() / 2]); } cout << ans << '\n'; 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...