Submission #248382

#TimeUsernameProblemLanguageResultExecution timeMemory
248382sahil_kPalembang Bridges (APIO15_bridge)C++14
22 / 100
161 ms3640 KiB
#include <iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; int main () { int k, n; cin >> k >> n; vector<int> vals; char ai, ci; int bi, di; long long o = 0; for (int i=0; i<n; i++) { cin >> ai >> bi >> ci >> di; if (ai != ci) { vals.push_back(bi); vals.push_back(di); } else { o += abs(bi-di); } } o += vals.size()/2; sort(vals.begin(), vals.end()); if (k == 1) { int mid = vals[vals.size()/2]; for (auto i: vals) { o += abs(mid-i); } cout << o << 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...