제출 #518801

#제출 시각아이디문제언어결과실행 시간메모리
518801sliviu쌀 창고 (IOI11_ricehub)C++17
17 / 100
18 ms1920 KiB
#include <bits/stdc++.h> #include "ricehub.h" using namespace std; int besthub(int n, int L, int a[], long long cmax) { long long curcost = 0; int sol, cursol = 1; queue<int> l, r; l.emplace(0); for (int i = 1; i < n; ++i) r.emplace(i); while (!r.empty() && a[r.front()] - a[0] <= cmax - curcost) { ++cursol, curcost += a[r.front()] - a[0]; r.pop(); } sol = cursol; for (int i = 1; i < n; ++i) { curcost += 1LL * (a[i] - a[i - 1]) * l.size(); curcost -= 1LL * (a[i] - a[i - 1]) * (cursol - l.size()); while (curcost > cmax) { assert(!l.empty()); curcost -= a[i] - a[l.front()]; --cursol; l.pop(); } while (!r.empty() && a[r.front()] - a[i] <= cmax - curcost) { ++cursol; curcost += a[r.front()] - a[i]; r.pop(); } l.emplace(i); sol = max(sol, cursol); } return sol; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...