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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lint;
int main() {
int n, k;
cin >> k >> n;
lint s = 0, m = 0;
vector<pair<lint, lint> > nums;
for (int x = 0; x < n; x ++){
char a, b;
lint i, j;
cin >> a >> i >> b >> j;
if (a == b){
s += abs(i - j);
}else {
nums.push_back(make_pair(i+j, i));
m += i;
m += j;
}
}
if (k == 1){
lint i = (m + nums.size()) / (nums.size()*2);
m = 0;
for (pair<lint, lint> x: nums){
lint a = x.second, b = x.first-x.second;
m += abs(a-i) + abs(b-i);
}
}
m += nums.size();
cout << m+s << endl;
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... |