제출 #1105268

#제출 시각아이디문제언어결과실행 시간메모리
1105268pedroslreyFish 3 (JOI24_fish3)C++14
9 / 100
2062 ms6608 KiB
#include <bits/stdc++.h> using namespace std; using lli = long long; int main() { int n; lli d; cin >> n >> d; vector<lli> cs(n); for (lli &c: cs) cin >> c; int q; cin >> q; while (q--) { int l, r; cin >> l >> r; --l; --r; lli cnt = 0; lli lst = cs[r]; bool ok = true; for (int i = r - 1; i >= l; --i) { if (cs[i] <= lst) { lst = cs[i]; continue; } cnt += (cs[i] - lst + d - 1)/d; lst = cs[i] - ((cs[i] - lst + d - 1)/d)*d; if (lst < 0) { ok = false; break; } } if (!ok) cout << "-1\n"; else cout << cnt << "\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...