제출 #677502

#제출 시각아이디문제언어결과실행 시간메모리
677502stanislavpolynMeasures (CEOI22_measures)C++17
24 / 100
1573 ms3620 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 = 4e5 + 5; int n, m; ll D; ll a[N]; ll b[N]; ll d[N]; ll suff[N]; int rnd(int l, int r) { return rng() % (r - l + 1) + l; } ll T[N]; //bool subtask = 1; //ve<ll> v; //ve<ll> pos; //void add(ll x) { // assert(is_sorted(all(v))); // int idx = sz(v) - 1; // fr (i, 0, sz(v) - 1) { // if (x > v[i]) { // idx = i - 1; // break; // } // } // // ll myPos = -1; // if (idx - 1 >= 0) { // myPos = max(x, pos[idx - 1] + D); // } else { // myPos = x; // } //} 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] = rnd(1, int(100)); a[i] *= 2; } // sort(a + 1, a + 1 + n); // fr (i, 1, n) { // pos[] // } ll last = -1; fr (i, 1, m) { ll x; cin >> x; x *= 2; // x *= 2; a[++n] = x; sort(a + 1, a + 1 + n); ll last = a[1]; ll ans = 0; fr (j, 2, n) { if (a[j] - last >= D) { last = a[j]; continue; } umx(ans, abs(a[j] - (last + D))); last += D; } // cout << ans << "\n"; // // auto possible = [&](ll t, bool flag = 0) { // fr (i, 1, n) b[i] = a[i]; // // fr (i, 1, n) { // ll have = t; // if (i > 1) { // ll x = b[i] - b[i - 1]; // if (x < D) { // if (D - x > t) { // return 0; // } // have -= max(0LL, 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); // } // } // if (flag) { // fr (i, 1, n) { // if (b[i] < a[i]) cout << "-1 "; // else cout << "+1 "; // } // cout << "\n"; // } // // return 1; // }; // // ll l = 0; // ll r = 2e18; // while (l < r) { // ll mid = l + ((r - l) >> 1); // if (possible(mid)) { // r = mid; // } else { // l = mid + 1; // } // } // assert(possible(l)); // // // possible(l, 1); //// l /= 2; ans /= 2; cout << ans / 2; if (ans % 2) cout << ".5"; cout << "\n"; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:106:8: warning: unused variable 'last' [-Wunused-variable]
  106 |     ll last = -1;
      |        ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...