#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;
int 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+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 |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 8 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 8 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |