Submission #650746

#TimeUsernameProblemLanguageResultExecution timeMemory
650746AmirHPalembang Bridges (APIO15_bridge)C++14
22 / 100
46 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 n, k; vector<pair<int, pair<int, int>>> v; ll sum = 0; void input() { cin >> k >> n; if(k == 1) { vector<int> cnt; for(int i = 1; i <= n; i++) { char a, b; int x, y; cin >> a >> x >> b >> y; if(a != b) { sum++; cnt.pb(x); cnt.pb(y); } else { sum += abs(x - y); } } sort(cnt.begin(), cnt.end()); int mid = cnt[(cnt.size() - 1) / 2]; for(auto i : cnt) { sum += abs(i - mid); } } // else { // // } // for(int i = 1; i <= n; i++) { // char a, b; // int x, y; // cin >> a >> x >> b >> y; // if(a != b) // v.pb({x + y, {x, y}}); // else // sum += abs(x - y); // } } int main() { faster; input(); cout << sum; }
#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...