제출 #653002

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
6530022022-10-25 11:40:26StickfishDungeon 3 (JOI21_ho_t5)C++17
11 / 100
4051 ms6368 KiB
#include <iostream>
#include <vector>
#include <deque>
using namespace std;
using ll = long long;
const int MAXN = 2e5 + 123;
ll eng[MAXN];
ll cost[MAXN];
ll get_ans(int l, int r, int mxeng) {
deque<pair<ll, ll>> dq;
ll eng_total = 0;
ll ans = 0;
for (int i = l; i < r; ++i) {
while (dq.size() && dq.back().first >= cost[i]) {
eng_total -= dq.back().second;
dq.pop_back();
}
if (eng_total < mxeng)
dq.push_back({cost[i], mxeng - eng_total});
eng_total = mxeng;
if (eng[i] > eng_total) {
return -1;
}
ll eng_need = eng[i];
while (eng_need > 0) {
if (eng_need >= dq.front().second) {
eng_need -= dq.front().second;
ans += dq.front().first * dq.front().second;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...