Submission #114136

#TimeUsernameProblemLanguageResultExecution timeMemory
114136fedoseevtimofeyPalembang Bridges (APIO15_bridge)C++14
22 / 100
52 ms4412 KiB
#include <bits/stdc++.h> #define int long long using namespace std; typedef long long ll; typedef long double ld; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20); #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int k, n; cin >> k >> n; ll res = 0; vector <int> a; for (int i = 0; i < n; ++i) { char p, q; int x, y; cin >> p >> x >> q >> y; if (p != q) { ++res; a.push_back(x); a.push_back(y); } else res += abs(x - y); } sort(a.begin(), a.end()); int x = a[(int)a.size() / 2]; for (auto y : a) res += abs(x - y); cout << res << '\n'; }
#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...