Submission #993979

#TimeUsernameProblemLanguageResultExecution timeMemory
993979a5a7Palembang Bridges (APIO15_bridge)C++14
22 / 100
73 ms7356 KiB
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template <class T> using indexedset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; typedef long long ll; int main(){ int k, n; cin >> k >> n; vector<pair<ll, ll>> deals; ll ans = 0; for (int i = 0; i < n; i++){ char a, b; ll c, d; cin >> a >> c >> b >> d; if (a == b) ans += max(d,c)-min(d,c); else deals.push_back({min(c,d), max(c,d)}); } if (k == 1){ vector<ll> v; for (auto x : deals) v.push_back(x.first), v.push_back(x.second); sort(v.begin(), v.end()); ll med = v[v.size()/2]; for (ll x : v) ans += abs(x-med); ans += deals.size(); } cout << ans << endl; }
#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...