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;
#define int long long
#define pii pair<int, int>
int32_t 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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |