제출 #1128584

#제출 시각아이디문제언어결과실행 시간메모리
1128584fzyzzz_zFish 3 (JOI24_fish3)C++20
9 / 100
2095 ms3748 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 524288; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; ll d; cin >> n >> d; vector<ll> oc(n); for (auto & x: oc) { cin >> x; } int q; cin >> q; while (q--) { int ql, qr; cin >> ql >> qr; ql--; qr--; ll last = (1LL << 41); ll ans = 0; for (int i = qr; i >= ql; --i) { if (oc[i] <= last) { last = oc[i]; } else { ll ops = ((oc[i] - last) + d - 1) / d; ans += ops; last = oc[i] - ops * d; } } cout << (last < 0LL ? -1 : ans) << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...