Submission #1106533

#TimeUsernameProblemLanguageResultExecution timeMemory
1106533Trisanu_DasFish 3 (JOI24_fish3)C++17
9 / 100
2065 ms7640 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { cin.tie(nullptr)->sync_with_stdio(false); int n, d; cin >> n >> d; int c[n]; for (int i = 0; i < n; i++) cin >> c[i]; int q; cin >> q; for (int i = 0; i < q; i++) { int l, r; cin >> l >> r; --l; --r; int ans = 0, prv = c[r]; for (int j = r - 1; j >= l; j--) { int cur = c[j] - prv; if (cur < 0) prv = c[j]; else { int x = (cur + d - 1) / d; ans += x; prv = c[j] - (d * x); } } if (prv < 0) cout << -1 << '\n'; else cout << 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...