# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1054213 | 2024-08-12T07:40:21 Z | Adomas08 | Palembang Bridges (APIO15_bridge) | C++14 | 57 ms | 3480 KB |
#include <bits/stdc++.h> using namespace std; int k, n; int findmedian(vector<int> j){ j.erase(remove(j.begin(), j.end(), -1), j.end()); sort (j.begin(), j.end()); return (j[j.size() / 2] + j[j.size() / 2 - 1]) / 2; } int main(){ long long ans = 0, cur = 0, maxs = -1, ist, num = 0; priority_queue <int> q; int passed = 0; int k, n; cin >> k >> n; int a[n*2]; vector <int> v; char b[n], d[n]; int z[n]; ist = n; for (int i = 0; i < n; i++){ z[i] = 0; cin >> b[i] >> a[i*2] >> d[i] >> a[i*2+1]; if (b[i] == d[i]){ z[i] = 1; ist--; v.push_back(-1); v.push_back(-1); } else { v.push_back(a[i*2]); v.push_back(a[i*2+1]); } if (a[i*2] > a[i*2+1]){ int temp = a[i*2]; a[i*2] = a[i*2+1]; a[i*2+1] = temp; } } int f; if (k == 1){ while (k--){ f = findmedian(v); for (int i = 0; i < n; i++){ if (f >= a[i*2] && f <= a[i*2+1]){ v[i*2] = -1; v[i*2+1] = -1; } } } for (int i = 0; i < n; i++){ if (b[i] == d[i]){ ans += a[i*2+1] - a[i*2]; } else{ if (v[i*2] == -1){ ans += a[i*2+1] - a[i*2] + 1; } else{ if (f < a[i*2]) ans += 1 + a[i*2+1] - a[i*2] + 2 * (a[i*2] - f); if (f > a[i*2+1]) ans += 1 + a[i*2+1] - a[i*2] + 2 * (f - a[i*2+1]); } } } } else{ } cout << ans; }
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 | 1 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 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 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 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 | 464 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 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 | 24 ms | 3480 KB | Output is correct |
13 | Correct | 57 ms | 3460 KB | Output is correct |
14 | Correct | 36 ms | 3024 KB | Output is correct |
15 | Correct | 33 ms | 2096 KB | Output is correct |
16 | Correct | 37 ms | 3356 KB | Output is correct |
17 | Correct | 49 ms | 3268 KB | Output is correct |
18 | Correct | 47 ms | 3272 KB | Output is correct |
19 | Correct | 54 ms | 3276 KB | Output is correct |
20 | Correct | 43 ms | 3272 KB | Output is correct |
21 | Correct | 50 ms | 3272 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 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 | 600 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |