# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
971804 | 2024-04-29T10:38:27 Z | nguyentunglam | Measures (CEOI22_measures) | C++17 | 80 ms | 35512 KB |
#include<bits/stdc++.h> #define all(v) v.begin(), v.end() #define endl "\n" using namespace std; const int N = 4e5 + 30; int n, m, d; int a[N]; long long T[4][N << 2]; void up(int s, int l, int r, int pos, int val) { if (l == r) { T[0][s] = 1; T[1][s] = val; T[2][s] = d -val; return; } int mid = l + r >> 1; if (pos <= mid) up(s << 1, l, mid, pos, val); else up(s << 1 | 1, mid + 1, r, pos, val); T[0][s] = T[0][s << 1] + T[0][s << 1 | 1]; T[1][s] = max(T[1][s << 1 | 1], T[1][s << 1] + T[0][s << 1 | 1] * d); T[2][s] = max(T[2][s << 1], T[2][s << 1 | 1] + T[0][s << 1] * d); T[3][s] = max({T[3][s << 1], T[3][s << 1 | 1], T[1][s << 1] + T[2][s << 1 | 1]}); } int32_t main() { #define task "" cin.tie(0) -> sync_with_stdio(0); if (fopen("task.inp", "r")) { freopen("task.inp", "r", stdin); freopen("task.out", "w", stdout); } if (fopen(task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } cin >> n >> m >> d; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = n + 1; i <= n + m; i++) cin >> a[i]; vector<pair<int, int> > rrh; for(int i = 1; i <= n + m; i++) rrh.emplace_back(a[i], i); sort(all(rrh)); rrh.resize(unique(all(rrh)) - rrh.begin()); for(int i = 1; i <= 4 * (n + m); i++) T[0][i] = T[1][i] = T[2][i] = -1e18; auto update = [&] (int i) { int pos = upper_bound(all(rrh), make_pair(a[i], i)) - rrh.begin(); // cout << pos << endl; up(1, 1, n + m, pos, a[i]); }; for(int i = 1; i <= n; i++) update(i); for(int i = n + 1; i <= n + m; i++) { update(i); cout << T[3][1] / 2; if (T[3][1] % 2) cout << ".5"; cout << " "; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 6748 KB | Output is correct |
2 | Incorrect | 1 ms | 6748 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 6748 KB | Output is correct |
2 | Incorrect | 1 ms | 6748 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 80 ms | 35512 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 80 ms | 35512 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |