# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1019189 | codefox | Palembang Bridges (APIO15_bridge) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
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;
}