제출 #1219572

#제출 시각아이디문제언어결과실행 시간메모리
1219572MateiKing80Measures (CEOI22_measures)C++20
0 / 100
1596 ms8780 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int ll using pii = pair<int, int>; #define fr first #define sc second signed main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m, d; cin >> n >> m >> d; swap(m, n); n += m; vector<pii> a, asort; vector<int> pos(n + 1); asort.push_back({0, 0}); a.push_back({0, 0}); for (int i = 1; i <= n; i ++) { int x; cin >> x; a.push_back({x, i}); asort.push_back({x, i}); } sort(asort.begin(), asort.end()); for (int i = 1; i <= n; i ++) pos[asort[i].sc] = i; int ans = 0; for (int i = 1; i <= n; i ++) { int nrActive = 0; for (int j = 1; j < pos[i]; j ++) if (asort[j].sc < i) nrActive ++; for (int j = 1; j < pos[i]; j ++) if (asort[j].sc < i) { ans = max(ans, nrActive * d - (a[i].fr - asort[j].fr)); nrActive --; } if (i > m) { cout << ans / 2; if (ans % 2 == 1) cout << ".5"; cout << " "; } } cout << '\n'; } /* ans = max(i<j)(1/2*((j - i) * d - (aj - ai))); cred */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...