#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 2;
struct inp {
char a, b;
int x, y;
void read() { cin >> a >> x >> b >> y; }
} arr[N];
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int k, n; cin >> k >> n;
for (int i = 1; i <= n; i++) arr[i].read();
if (k == 1) {
vector<int> tmp;
for (int i = 1; i <= n; i++)
tmp.push_back(arr[i].x), tmp.push_back(arr[i].y);
sort(tmp.begin(), tmp.end());
int med = tmp[n];
long long ans = 0;
for (int i = 1; i <= n; i++) {
if (arr[i].a != arr[i].b)
ans += abs(arr[i].x - med) + abs(arr[i].y - med) + 1;
else ans += abs(arr[i].y - arr[i].x);
}
cout << ans << '\n';
} else {
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |