Submission #677427

#TimeUsernameProblemLanguageResultExecution timeMemory
677427stanislavpolynMeasures (CEOI22_measures)C++17
0 / 100
1580 ms468 KiB
#include <bits/stdc++.h> #define fr(i, a, b) for (int i = (a); i <= (b); ++i) #define rf(i, a, b) for (int i = (a); i >= (b); --i) #define fe(x, y) for (auto& x : y) #define fi first #define se second #define pb push_back #define mp make_pair #define mt make_tuple #define all(x) (x).begin(), (x).end() #define pw(x) (1LL << (x)) #define sz(x) (int)(x).size() using namespace std; mt19937_64 rng(228); #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define fbo find_by_order #define ook order_of_key template <typename T> bool umn(T& a, T b) { return a > b ? (a = b, 1) : 0; } template <typename T> bool umx(T& a, T b) { return a < b ? (a = b, 1) : 0; } using ll = long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; template <typename T> using ve = vector<T>; const int N = 3e5 + 5; int n, m, d; int a[N]; int b[N]; int main() { #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #else ios::sync_with_stdio(0); cin.tie(0); #endif cin >> n >> m >> d; d *= 2; fr (i, 1, n) { cin >> a[i]; a[i] *= 2; } fr (i, 1, m) { int x; cin >> x; x *= 2; a[++n] = x; sort(a + 1, a + 1 + n); auto possible = [&](ll t) { fr (i, 1, n) b[i] = a[i]; fr (i, 1, n) { int have = t; if (i > 1) { int x = b[i] - b[i - 1]; if (x < d) { if (d - x > t) { return 0; } have -= max(0, d - x); b[i] = b[i - 1] + d; } } if (i == 1 || b[i] - b[i - 1] > d) { if (i == 1) b[i] -= t; else b[i] -= min(b[i] - b[i - 1] - d, have); } } return 1; }; ll l = 0; ll r = 4e9; while (l < r) { ll mid = l + ((r - l) >> 1); if (possible(mid)) { r = mid; } else { l = mid + 1; } } assert(possible(l)); cout << l / 2; if (l % 2) cout << ".5"; cout << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...