제출 #1329629

#제출 시각아이디문제언어결과실행 시간메모리
1329629ErJTrains (BOI24_trains)C++20
21 / 100
2094 ms2772 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define pp pair<ll, ll>
#define vp vector<pp>
#define inf 1000000000
#define mod 1000000007

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n;
    cin >> n;
    vp A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i].first >> A[i].second;
    }
    ll k = 200;
    ll ANS = 0;
    vi ans(n, 0);
    ans[0] = 1;

    for(int i = 0; i < n; i++){
        ANS += ans[i];
        ANS %= mod;
        if(A[i].first == 0) continue;
        for(int j = 1; j <= A[i].second; j++){
            ll pos = i + j * A[i].first;
            if(pos >= n) break;
            ans[pos] += ans[i];
            ans[pos] %= mod;
        }
    }

    cout << ANS << '\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...