# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1095187 | 2024-10-01T13:53:07 Z | dpsaveslives | Palembang Bridges (APIO15_bridge) | C++17 | 36 ms | 4552 KB |
#include <bits/stdc++.h> #define ll long long #define f first #define s second using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int K,N; cin >> K >> N; if(K == 2){ cout << 0 << "\n"; return 0; } ll ans = 0; vector<int> vec; vector<pair<int,int>> dif; for(int i = 0;i<N;++i){ char p1,p2; int s,t; cin >> p1 >> s >> p2 >> t; if(p1 != p2){ vec.push_back(s); vec.push_back(t); dif.push_back({s,t}); } else{ ans += abs(s-t); } } if(!vec.size()){ cout << ans << "\n"; return 0; } sort(vec.begin(),vec.end()); int med = vec[vec.size()/2]; for(int i = 0;i<dif.size();++i){ ans += abs(dif[i].f-med)+abs(dif[i].s-med)+1; } cout << ans << "\n"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 604 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 456 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 468 KB | Output is correct |
5 | Correct | 1 ms | 508 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 604 KB | Output is correct |
9 | Correct | 1 ms | 348 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 | 3000 KB | Output is correct |
13 | Correct | 29 ms | 4548 KB | Output is correct |
14 | Correct | 21 ms | 3304 KB | Output is correct |
15 | Correct | 17 ms | 2916 KB | Output is correct |
16 | Correct | 16 ms | 3784 KB | Output is correct |
17 | Correct | 19 ms | 4388 KB | Output is correct |
18 | Correct | 36 ms | 3996 KB | Output is correct |
19 | Correct | 27 ms | 4552 KB | Output is correct |
20 | Correct | 18 ms | 3996 KB | Output is correct |
21 | Correct | 27 ms | 4288 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |