Submission #650670

#TimeUsernameProblemLanguageResultExecution timeMemory
650670AmirHPalembang Bridges (APIO15_bridge)C++14
22 / 100
49 ms3552 KiB
#include<bits/stdc++.h> using namespace std; typedef long long int ll; #define pb push_back #define faster ios::sync_with_stdio(0), cin.tie(0), cout.tie(0) #define pii pair<int, int> const int MAX_N=2e5+25; int k, n; void solve() { cin >> k >> n; vector<int> v; ll sum = 0; for(int i = 1; i <= n; i++) { char a, b; int x, y; cin >> a >> x >> b >> y; if(a == b) sum += abs(x - y); else { sum++; v.pb(x); v.pb(y); } } sort(v.begin(), v.end()); int mid = v[(v.size() - 1) / 2]; for(auto i : v) { sum += abs(i - mid); } cout << sum; } int main() { faster; solve(); }
#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...