#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define ll long long
#define pii pair <int, int>
#define sz size()
const int N = 2e5 + 5;
vector <ll> v;
char s[N], f[N];
ll a[N], b[N];
int k, n;
int main() {
// freopen ("input.txt", "r", stdin);
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> k >> n;
for (int i = 1; i <= n; ++i) {
cin >> s[i] >> a[i] >> f[i] >> b[i];
if (s[i] != f[i]) {
v.pb (a[i]);
v.pb (b[i]);
}
}
sort (v.begin(), v.end());
ll idx = v[(int)v.sz / 2];
ll sum = 0;
for (int i = 1; i <= n; ++i) {
if (s[i] == f[i]) {
sum += abs (a[i] - b[i]);
}
else {
sum += abs (idx - a[i]);
sum += abs (idx - b[i]);
sum++;
}
}
cout << sum;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
4700 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
4700 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
4696 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
4696 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
4656 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |