Submission #1084760

# Submission time Handle Problem Language Result Execution time Memory
1084760 2024-09-06T23:18:34 Z zxcigan Trains (BOI24_trains) C++17
0 / 100
19 ms 4688 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int long long
const int N = 2e5;
const int mod = 1e9 + 7;
const int B = 335;
int dp[N];
int32_t main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    dp[1] = 1;
    int s = 0;
    vector<vector<int>> add (B + 1, vector<int> (B + 1, 0));
    set<array<int,2>> st;
    int C = 0;
    for (int i = 1; i <= n; ++i) {
        int x, d;
        cin >> d >> x;
        if (i != 1) dp[i] = C;
        if (x && d) {
            (C += dp[i]) %= mod;
            st.insert ({i + x * d,dp[i]});
        }
        while ((int)st.size() && (*st.begin())[0] == i) {
            array<int,2> v = (*st.begin());
            C -= v[1];
            while (C < 0) C += mod;
            st.erase (st.begin());
        }
        (s += dp[i]) %= mod;
    }
    cout << s << '\n';
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Correct 2 ms 1708 KB Output is correct
3 Correct 2 ms 1628 KB Output is correct
4 Correct 3 ms 1960 KB Output is correct
5 Incorrect 10 ms 1880 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 4688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1112 KB Output isn't correct
2 Halted 0 ms 0 KB -