| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1359928 | Peti | Fish 3 (JOI24_fish3) | C++20 | 2095 ms | 5140 KiB |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
long long d;
cin>>n>>d;
vector<long long> v(n);
for(auto &x : v) cin>>x;
int q;
cin>>q;
while(q--) {
int l, r;
cin>>l>>r;
--l;
long long ans = 0, carry = 0;
for(int i = r-2; i >= l; i--) {
if(v[i] > v[i + 1]) carry += (v[i] - v[i + 1] + d - 1) / d;
else carry += (v[i] - v[i + 1]) / d;
if(carry < 0) carry = 0;
if(v[i] - carry * d < 0) {
ans = -1;
break;
}
ans += carry;
}
cout << ans << '\n';
}
return 0;
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
