Submission #991340

# Submission time Handle Problem Language Result Execution time Memory
991340 2024-06-02T06:57:49 Z Andrey Trains (BOI24_trains) C++14
16 / 100
104 ms 158172 KB
#include<bits/stdc++.h>
using namespace std;

int bruh[100001][400];
const int MOD = 1e9+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,a,b;
    cin >> n;
    vector<pair<int,int>> haha(n+1);
    for(int i = 0; i < n; i++) {
        cin >> a >> b;
        haha[i] = {a,b};
    }
    reverse(haha.begin(),haha.end());
    vector<int> dp(n+1,1);
    dp[0] = 0;
    for(int i = 0; i < 400; i++) {
        bruh[0][i] = 0;
    }
    for(int i = 1; i <= n; i++) {
        a = haha[i].first;
        b = haha[i].second;
        if(a*a <= n) {
            if(i > a) {
                dp[i]+=bruh[i-a][a];
                dp[i]%=MOD;
            }
            if(i > a*(b+1)) {
                dp[i]-=bruh[i-a*(b+1)][a];
                dp[i]+=MOD;
                dp[i]%=MOD;
            }
        }
        else {
            for(int j = i-a; j >= max(0,j-a*b); j-=a) {
                dp[i]+=dp[j];
                dp[i]%=MOD;
            }
        }
        for(int j = 1; j*j <= n; j++) {
            if(j <= i) {
                bruh[i][j] = (bruh[i-j][j]+dp[i])%MOD;
            }
            else {
                bruh[i][j] = dp[i];
            }
        }
    }
    cout << dp[n];
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 464 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Runtime error 3 ms 604 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 464 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Runtime error 3 ms 604 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 3 ms 10840 KB Output is correct
3 Correct 2 ms 8796 KB Output is correct
4 Correct 4 ms 14940 KB Output is correct
5 Correct 62 ms 122524 KB Output is correct
6 Correct 97 ms 158172 KB Output is correct
7 Correct 92 ms 158120 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 5 ms 17156 KB Output is correct
12 Correct 104 ms 158004 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 5 ms 16988 KB Output is correct
15 Correct 98 ms 158080 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 1624 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 464 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Runtime error 3 ms 604 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -