Submission #1110168

#TimeUsernameProblemLanguageResultExecution timeMemory
1110168lamlamjjdoFish 3 (JOI24_fish3)C++17
0 / 100
1292 ms5068 KiB
#include<bits/stdc++.h> using namespace std; int n,d; long long a[5000]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >>n>>d; for(int i=1;i<=n;i++){ cin >>a[i]; } int q; cin >>q; while(q--){ int l,r; cin >>l>>r; long long lst=a[r]; long long c=0; bool t=true; for(int i=r-1;i>=l;i--){ if(a[i]>lst){ long long g=(a[i]-lst+d-1)/d; if(a[i]<g*d){ t=false; break; } lst=a[i]-g*d; c+=g; } else lst=a[i]; } if(t)cout <<c<<'\n'; else cout<<-1<<'\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...