Submission #799629

#TimeUsernameProblemLanguageResultExecution timeMemory
799629GusterGoose27Measures (CEOI22_measures)C++17
24 / 100
1569 ms3152 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll dp(int n, vector<int> &x, int d) { ll final = 0; // times 2 ll change = 2*d; // times 2 for (int i = 1; i < n; i++) { int pos = x[i]-x[i-1]; change -= 2*pos; if (change >= final) { /* (change-npos)+final = npos => npos = (change+final)/2; */ assert((change&1) == (final&1)); ll npos = (change+final)/2; assert(npos <= change); final += change-npos; change = npos; } else if (-change >= final) { ll npos = -final; assert(npos >= change); change = npos; } change += 2*d; } return final; } void print(ll a) { cout << a/2; if (a & 1) cout << ".5"; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m, d; cin >> n >> m >> d; vector<int> elems; for (int i = 0; i < n; i++) { int x; cin >> x; elems.push_back(x); } for (int j = 0; j < m; j++) { int x; cin >> x; elems.push_back(x); sort(elems.begin(), elems.end()); // appreciate my laziness if (j > 0) cout << ' '; print(dp(n+j+1, elems, d)); } 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...