This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,d,x,ways=1;
cin>>n;
pair<int,int> stops[n+1];
for(int i=0;i<n;++i){
cin>>d>>x;
stops[i+1].first=d;
stops[i+1].second=x;
}
for(int i=1;i<=n;++i){
bool reachable=false;
for(int j=1;j<i;++j){
if(stops[j].first==0){
continue;
}
if((i-j)%stops[j].first==0){
reachable=true;
}
}
if(i==1){
reachable=true;
}
if(reachable){
int moves=0;
if(stops[i].first!=0){
moves=min(stops[i].second,(n-i)/stops[i].first);
}
ways+=moves;
}
}
cout<<ways<<'\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... |