Submission #1027399

# Submission time Handle Problem Language Result Execution time Memory
1027399 2024-07-19T05:44:13 Z stdfloat Boat (APIO16_boat) C++17
0 / 100
1 ms 604 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const int md = (int)1e9 + 7;

const int N = (int)1e6 + 1;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);

    int n;
    cin >> n;

    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];

    assert(*max_element(b.begin(), b.end()) < N);

    vector<int> dp(N);
    for (int i = 0; i < n; i++) {
        for (int j = b[i]; j >= a[i]; j--) {
            dp[j] = (dp[j] + 1) % md;
            for (int k = 1; k < j; k++) dp[j] = (dp[j] + dp[k]) % md;
        }
    }

    int sm = 0;
    for (auto i : dp) sm = (sm + i) % md;

    cout << sm;
}

/*sub1
vector<int> dp(n);
for (int i = 0; i < n; i++) {
    dp[i] = 1;
    for (int j = 0; j < i; j++) {
        if (a[j] < a[i]) dp[i] = (dp[i] + dp[j]) % md;
    }
}

int sm = 0;
for (auto i : dp) sm = (sm + i) % md;

cout << sm;
*/
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -