Submission #348027

#TimeUsernameProblemLanguageResultExecution timeMemory
348027ThinGarfieldPalembang Bridges (APIO15_bridge)C++11
0 / 100
1 ms492 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; #define F first #define S second using pip = pair<int, pii>; // (s+t)/2, s, t constexpr int sc = 4; constexpr int maxx = 2e9 + 18; constexpr int maxn = 1e5 + 18; int cost; int n, k; vector<int> endpts; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> k >> n; for (int i = 0; i < n; i++) { char s1, t1; int s, t; cin >> s1 >> s >> t1 >> t; if (s1 == t1) { cost += sc * abs(t - s); // cout << '+' << sc * abs(t - s) << '\n'; } else { endpts.push_back(sc * s); endpts.push_back(sc * t); } } sort(endpts.begin(), endpts.end()); if (k == 1) { int eps = endpts.size() / 2; int bloc = (endpts[eps] + endpts[eps - 1]) / 2; for (int x : endpts) { cost += abs(bloc - x); // cout << '+' << abs(bloc - x) << '\n'; } cost += (eps * sc); // cout << '+' << eps * sc << '\n'; cout << cost / sc << '\n'; } return 0; }
#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...