Submission #1353198

#TimeUsernameProblemLanguageResultExecution timeMemory
1353198idkcpBoat (APIO16_boat)C++20
0 / 100
1 ms344 KiB
/**
 *       author:  Vi Gia Huy
 *     Vi Gia Huy will win APIO
**/

#include <bits/stdc++.h>

using namespace std;

const long long MOD = 1e9 + 7;
const int N = 555;
int n;
long long a[N], b[N];

namespace sub1 {
    long long dp[N];

    void sol() {
        for (int i = 1; i <= n; i++) {
            dp[i] = 1;
            for (int j = 1; j < i; j++) {
                if (a[i] >= a[j]) {
                    dp[i] = (dp[i] + dp[j]) % MOD;
                }
            }
        }

        long long ans = 0;
        for (int i = 1; i <= n; i++) ans = (ans + dp[i]) % MOD;

        cout << ans;

        return;
    }
}

namespace sub2 {
    void sol() {

        return;
    }
}

namespace sub3 {
    void sol() {

        return;
    }
}

namespace sub4 {
    void sol() {

        return;
    }
}

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

    bool checksub1 = true;
    long long total = 0;

    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i];
        total += b[i] - a[i];
        if (a[i] != b[i]) checksub1 = false;
    }

    if (n <= 500 && checksub1) sub1::sol();
    else if (n <= 500 && total <= 1e6) sub2::sol();
    else if (n <= 100) sub3::sol();
    else sub4::sol();

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...