# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1026271 | mareksb | Trains (BOI24_trains) | C++17 | 192 ms | 259068 KiB |
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;
constexpr int64_t N = 1e5+5;
constexpr int64_t mod = 1e9+7;
int64_t dp[N+5]{};//number of paths starting from i
constexpr int64_t d=320;
int64_t c[N+5][d+5]{};//sum dp given (start pos, step size)
int main() {
int64_t n;
cin>>n;
int64_t a[n+1],b[n+1];
for(int64_t i=1;i<=n;i++){
cin>>a[i]>>b[i];
}
for(int64_t i=n;i>0;i--){
dp[i]=1;
if(a[i]){
if(a[i]>=d){
for(int64_t j=1;j<=b[i];j++){
int64_t pos=i+j*a[i];
if(pos>n)break;
dp[i]=(dp[i]+dp[pos])%mod;
}
}
else{
int64_t fin = min(i+a[i]*b[i],n);
dp[i]=(dp[i]+c[i][a[i]]-c[fin][a[i]]+mod)%mod;
}
}
# | 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... |