# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
971727 | 2024-04-29T08:19:00 Z | nguyentunglam | Measures (CEOI22_measures) | C++17 | 1500 ms | 3964 KB |
#include<bits/stdc++.h> #define all(v) v.begin(), v.end() #define endl "\n" using namespace std; const int N = 2e5 + 30; int n, m, d; long long a[N]; int32_t main() { #define task "" cin.tie(0) -> sync_with_stdio(0); if (fopen("task.inp", "r")) { freopen("task.inp", "r", stdin); freopen("task.out", "w", stdout); } if (fopen(task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } cin >> n >> m >> d; d *= 2; for(int i = 1; i <= n; i++) cin >> a[i], a[i] *= 2; auto calc = [&] () { sort(a + 1, a + n + 1); auto check = [&] (long long time) { long long last = -1e18; for(int i = 1; i <= n; i++) { if (a[i] + time < last + d) return false; last = max(last + d, a[i] - time); } return true; }; long long l = 0, r = 1e17, last = -1; while (l <= r) { long long mid = l + r >> 1; if (check(mid)) { last = mid; r = mid - 1; } else l = mid + 1; } return last; }; while (m--) { ++n; cin >> a[n]; a[n] *= 2; long long ret = calc(); cout << ret / 2; if (ret % 2) cout << ".5"; cout << " "; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 344 KB | Output is correct |
2 | Correct | 2 ms | 348 KB | Output is correct |
3 | Correct | 2 ms | 348 KB | Output is correct |
4 | Correct | 3 ms | 348 KB | Output is correct |
5 | Correct | 2 ms | 348 KB | Output is correct |
6 | Correct | 2 ms | 348 KB | Output is correct |
7 | Correct | 2 ms | 348 KB | Output is correct |
8 | Correct | 2 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 344 KB | Output is correct |
2 | Correct | 2 ms | 348 KB | Output is correct |
3 | Correct | 2 ms | 348 KB | Output is correct |
4 | Correct | 3 ms | 348 KB | Output is correct |
5 | Correct | 2 ms | 348 KB | Output is correct |
6 | Correct | 2 ms | 348 KB | Output is correct |
7 | Correct | 2 ms | 348 KB | Output is correct |
8 | Correct | 2 ms | 348 KB | Output is correct |
9 | Correct | 230 ms | 1824 KB | Output is correct |
10 | Correct | 275 ms | 3944 KB | Output is correct |
11 | Correct | 178 ms | 3964 KB | Output is correct |
12 | Correct | 293 ms | 3932 KB | Output is correct |
13 | Correct | 185 ms | 3476 KB | Output is correct |
14 | Correct | 224 ms | 3916 KB | Output is correct |
15 | Correct | 226 ms | 3264 KB | Output is correct |
16 | Correct | 179 ms | 3932 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1598 ms | 756 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1598 ms | 756 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |