Submission #1111511

#TimeUsernameProblemLanguageResultExecution timeMemory
1111511zhehanTrains (BOI24_trains)C++14
0 / 100
126 ms1020 KiB
#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; } int reachable[n+1]; memset(reachable,0,sizeof(reachable)); reachable[1]=1; for(int i=1;i<=n;++i){ if(reachable[i]){ int moves=0; if(stops[i].first!=0){ moves=min(stops[i].second,(n-i)/stops[i].first); } for(int j=i;j<=moves*stops[i].first+1;j+=stops[i].first){ reachable[j]=1; } ways+=moves; } } cout<<ways<<'\n'; return 0; }
#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...