#include<bits/stdc++.h>
using namespace std;
vector<int> Data;
int main(){
int tmp,K;
cin>>tmp>>K;
long long int answer = 0;
for(int i=0;i<K;i++){
char tmp1,tmp2;
int tmp3,tmp4;
cin>>tmp1>>tmp3>>tmp2>>tmp4;
if(tmp1==tmp2) answer += abs(tmp3-tmp4);
else{
Data.push_back(tmp3);
Data.push_back(tmp4);
}
}
sort(Data.begin(),Data.end());
for(int i=0;i<(int)Data.size();i++){
answer += abs(Data[i]-Data[(int)Data.size()/2]);
}
cout << answer + (int)Data.size()/2;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
1 ms |
308 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
308 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
324 KB |
Output is correct |
8 |
Correct |
2 ms |
212 KB |
Output is correct |
9 |
Correct |
2 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
308 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
38 ms |
2124 KB |
Output is correct |
13 |
Correct |
82 ms |
3416 KB |
Output is correct |
14 |
Correct |
54 ms |
2580 KB |
Output is correct |
15 |
Correct |
48 ms |
2124 KB |
Output is correct |
16 |
Correct |
65 ms |
2828 KB |
Output is correct |
17 |
Correct |
71 ms |
3524 KB |
Output is correct |
18 |
Correct |
74 ms |
3132 KB |
Output is correct |
19 |
Correct |
80 ms |
3500 KB |
Output is correct |
20 |
Correct |
64 ms |
3036 KB |
Output is correct |
21 |
Correct |
74 ms |
3232 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
296 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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |