#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
using namespace std;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int k, n;
cin >> k >> n;
int ans = 0;
vector<int> a, b;
for (int i = 0; i < n; i++) {
char p, q;
int s, t;
cin >> p >> s >> q >> t;
if (p == q) {
ans += abs(s - t);
} else {
if (p == 'A') {
a.push_back(s);
b.push_back(t);
} else {
a.push_back(t);
b.push_back(s);
}
}
}
if (k == 1) {
int m = (int)a.size();
vector<int> c;
for (int i = 0; i < m; i++) {
c.push_back(a[i]);
c.push_back(b[i]);
}
sort(c.begin(), c.end());
ans += m;
for (int i = 0; i < 2 * m; i++) {
ans += abs(c[i] - c[m]);
}
cout << ans << '\n';
} else if (k == 2) {
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
504 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
380 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
464 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
16 ms |
4992 KB |
Output is correct |
13 |
Correct |
34 ms |
6372 KB |
Output is correct |
14 |
Correct |
25 ms |
5124 KB |
Output is correct |
15 |
Correct |
19 ms |
3868 KB |
Output is correct |
16 |
Correct |
20 ms |
5608 KB |
Output is correct |
17 |
Correct |
22 ms |
6408 KB |
Output is correct |
18 |
Correct |
27 ms |
5824 KB |
Output is correct |
19 |
Correct |
33 ms |
6280 KB |
Output is correct |
20 |
Correct |
34 ms |
6016 KB |
Output is correct |
21 |
Correct |
27 ms |
6056 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |