Submission #1098775

#TimeUsernameProblemLanguageResultExecution timeMemory
1098775gygMeasures (CEOI22_measures)C++17
0 / 100
1552 ms11708 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define arr array #define vct vector #define pii pair<int, int> #define fir first #define sec second const int N = 2e5 + 5, M = 2e5 + 5, INF = 1e18; int n, m, d; arr<int, N + M> ps; arr<int, N + M> ind, rv_ind, vl; struct Rng { int l, r, mn, mx; bool operator<(Rng oth) const { if (l == oth.l && r == oth.r) assert(false); if (l == oth.l) return r < oth.r; return l < oth.l; } }; void prcmp() { vct<pii> ord; for (int i = 1; i <= n + m; i++) ord.push_back({ps[i], i}); sort(ord.begin(), ord.end()); for (int i = 0; i < ord.size(); i++) { ind[ord[i].sec] = i + 1, rv_ind[i + 1] = ord[i].sec; vl[i + 1] = ord[i].fir - i * d; } } double gt_ans(int lst) { Rng rng = {0, 0, INF, -INF}; double ans = 0; for (int i = 1; i <= n + m; i++) { if (rv_ind[i] > lst) continue; if (vl[i] > rng.mx) { if (rng.l != 0) { rng.r = i - 1; } rng = {i, 0, vl[i], vl[i]}; } rng.mn = min(rng.mn, vl[i]); ans = max(ans, (rng.mx - rng.mn) / (double) 2); } return ans; } signed main() { // freopen("ms.in", "r", stdin); cin >> n >> m >> d; assert(n == 0); for (int i = 1; i <= n + m; i++) cin >> ps[i]; prcmp(); for (int i = 1; i <= n + m; i++) cout << gt_ans(i) << endl; }

Compilation message (stderr)

Main.cpp: In function 'void prcmp()':
Main.cpp:29:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i = 0; i < ord.size(); i++) {
      |                     ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...