Submission #1191616

#TimeUsernameProblemLanguageResultExecution timeMemory
1191616The_SamuraiMeasures (CEOI22_measures)C++20
59 / 100
1592 ms6844 KiB
// I stand with PALESTINE // #pragma GCC optimize("Ofast,O3") // #pragma GCC target("avx,avx2") #include "bits/stdc++.h" using namespace std; using ll = long long; using ld = double; const ld eps = 1e-6; /* v[0] - mid + d <= v[1] + mid max(v[0] - mid + 2d, v[1] - mid + d) <= v[2] + mid max(v[0] - mid + 3d, v[1] - mid + 2d, v[2] - mid + d) <= v[3] + mid max(v[0] - mid + 3d, v[1] - mid + 2d, v[2] - mid + d) = = max(v[0] - mid, v[1] - mid - d, v[2] - mid - 2d) + 3d = = max(v[0], v[1] - d, v[2] - 2d) + 3d - mid max(v[0], v[1] - d, v[2] - 2d) + 3d - mid <= v[3] + mid max(v[0], v[1] - d, v[2] - 2d) + 3d - mid <= v[3] + mid max(v[0], v[1] - d, v[2] - 2d) + 3d - v[3] <= 2 * mid (max(v[0], v[1] - d, v[2] - 2d) + 3d - v[3]) / 2 <= mid */ void out(ll x) { cout << x / 2; if (x % 2) cout << ".5"; cout << ' '; } void solve() { int n, m; ll d; cin >> n >> m >> d; vector<ll> a(n), b(m); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < m; i++) cin >> b[i]; auto v = a; sort(v.begin(), v.end()); ll mx = -1e18, ans = 0; auto recalc = [&]() -> void { mx = -1e18, ans = 0; for (int i = 0; i < v.size(); i++) { ans = max(ans, mx + i * d - v[i]); mx = max(mx, v[i] - i * d); } }; recalc(); for (int i = 0; i < m; i++) { if (v.empty() or v.back() <= b[i]) { v.emplace_back(b[i]); ans = max(ans, mx + ll(v.size() - 1) * d - v.back()); mx = max(mx, v.back() - ll(v.size() - 1) * d); } else { v.emplace_back(b[i]); sort(v.begin(), v.end()); recalc(); } out(ans); } } int main() { cin.tie(0)->sync_with_stdio(false); int queries = 1; #ifdef sunnatov freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); cin >> queries; #else // cin >> queries; #endif for (int test_case = 1; test_case <= queries; test_case++) { #ifdef sunnatov cout << "Test case: " << test_case << endl; #endif solve(); cout << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...