#include <bits/stdc++.h>
#define st first
#define nd second
using namespace std;
const long long INF = 1e10;
const int MOD = 1e9+7;
const int MAXN = 30000;
int n, k, ans, cnt;
vector < pair<int,int> > a;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
cin >> k >> n;
vector < int > v;
for(int i = 1; i <= n; i++) {
int x1, x2;
char c1, c2;
cin >> c1 >> x1 >> c2 >> x2;
if(c1 == c2) ans += abs(x2-x1);
else {
v.push_back(x1);
v.push_back(x2);
cnt++;
}
}
ans += cnt;
sort(v.begin(),v.end());
int x = v[(v.size()+1)/2 - 1];
for(int i = 0; i < v.size(); i++)
ans += abs(x-v[i]);
cout << ans;
}
Compilation message
bridge.cpp: In function 'int main()':
bridge.cpp:41:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < v.size(); i++)
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
700 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
824 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
824 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
824 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |