Submission #1019191

#TimeUsernameProblemLanguageResultExecution timeMemory
1019191codefoxPalembang Bridges (APIO15_bridge)C++14
0 / 100
1 ms604 KiB
#include <bits/stdc++.h> using namespace std; #define pii pair<int, int> int main() { int k, n; cin >> k >> n; vector<pii> jobs; vector<int> pos; int sol = 0; for (int i = 0; i < n; i++) { char c1, c2; int a, b; cin >> c1 >> a >> c2 >> b; if (c1!=c2) { jobs.push_back({a, b}); pos.push_back(a); pos.push_back(b); } else sol += abs(a-b); } sort(pos.begin(), pos.end()); if (k == 1) { int h = pos[pos.size()/2]; for (int ele:pos) sol += abs(ele-h); cout << sol+pos.size()/2; } return 0; }
#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...