#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz size()
const int N = 1e5 + 5;
ll n, k, goshmaly, x[N], y[N];
char s[N], d[N];
vector <int> v;
int main () {
// freopen("input.txt", "r", stdin);
cin >> k >> n;
for (int i = 1; i <= n; ++i) {
cin >> s[i] >> x[i] >> d[i] >> y[i];
if (s[i] == d[i]) {
goshmaly += abs (x[i] - y[i]);
}
else {
goshmaly++;
v.pb (x[i] + y[i]);
}
}
sort (v.begin(), v.end());
int n1 = (int)v.sz/2;
int med = v[n1]/2;
for(int i = 1; i <= n; i++){
if(s[i] != d[i]){
goshmaly += abs(med-x[i]) + abs(med-y[i]);
}
}
cout << goshmaly;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |