Submission #701325

#TimeUsernameProblemLanguageResultExecution timeMemory
701325PurpleCrayonMeasures (CEOI22_measures)C++17
0 / 100
1573 ms4936 KiB
#include <bits/stdc++.h> using namespace std; #define sz(v) int(v.size()) #define ar array typedef long long ll; const int N = 2e5+10, MOD = 998244353; const ll INF = 1e18+10; void solve() { int n, m, d; cin >> n >> m >> d; vector<int> a(n); for (auto& x : a) cin >> x; vector<int> b(m); for (auto& x : b) cin >> x; vector<pair<int, int>> v; for (int i = 0; i < n; i++) { v.emplace_back(a[i], i); } for (int i = 0; i < m; i++) { v.emplace_back(b[i], n + i); } sort(v.begin(), v.end()); vector<int> loc_a(n), loc_b(m); for (int i = 0; i < n + m; i++) { if (v[i].second < n) { loc_a[v[i].second] = i; } else { loc_b[v[i].second - n] = i; } } vector<ll> val(n + m, INF); for (int i = 0; i < n; i++) { val[loc_a[i]] = (long long) d * loc_a[i] - a[i]; } for (int i = 0; i < m; i++) { val[loc_b[i]] = (long long) d * loc_b[i] - b[i]; ll ans = 0; for (int x = 0; x < n + m; x++) if (val[x] != INF) { for (int y = x + 1; y < n + m; y++) if (val[y] != INF) { ans = max(ans, val[y] - val[x]); } } cout << (long double) ans / 2 << ' '; } cout << '\n'; } int main() { ios::sync_with_stdio(false); cin.tie(0); int T = 1; // cin >> T; while (T--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...