Submission #28322782


Source Code Expand

// #include <atcoder/all>
// using namespace atcoder;
// using mint = modint998244353;
// using mint = modint1000000007;
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,k,n) for (int i = (k); i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
// using P = pair<ll,ll>;


const ll INF = (ll)1e18;
// const int INF = (int)1e9+7;
template<typename T>
void chmin(T &a, T b) { a = min(a, b); }
template<typename T>
void chmax(T &a, T b) { a = max(a, b); }

template<typename T>
void print(vector<T> v) {
    int n = v.size();
    rep(i,n) {
        if (i == 0) cout << v[i];
        else cout << ' ' << v[i];
    }
    cout << endl;
}

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    const ll MAX = 3005;
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    const ll MOD = 998244353;

    vector<vector<ll>> dp(n, vector<ll>(MAX, 0));
    rep2(x,a[0],b[0]+1) dp[0][x] = 1;
    rep2(i,1,n) {
        rep2(x,a[i],b[i]+1) {
            rep2(k,a[i-1],x+1) {
                dp[i][x] += dp[i-1][k];
                dp[i][x] %= MOD;
            }
        }
    }

    ll ans = 0;
    rep(i,MAX) {
        ans += dp[n-1][i];
        ans %= MOD;
    }
    cout << ans << endl;

}

int main() {
    solve();
    return 0;
}

Submission Info

Submission Time
Task D - Between Two Arrays
User goropikari
Language C++ (GCC 9.2.1)
Score 0
Code Size 1450 Byte
Status TLE
Exec Time 2208 ms
Memory 73992 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 15
TLE × 6
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_small_00.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt, 01_small_04.txt, 01_small_05.txt, 01_small_06.txt, 01_small_07.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 03_same_00.txt, 03_same_01.txt, 04_min_00.txt, 04_min_01.txt, 05_max_00.txt, 05_max_01.txt, 06_minmax_00.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 9 ms 3656 KiB
00_sample_01.txt AC 3 ms 3544 KiB
00_sample_02.txt AC 2 ms 3668 KiB
01_small_00.txt AC 2 ms 3536 KiB
01_small_01.txt AC 2 ms 3680 KiB
01_small_02.txt AC 2 ms 3652 KiB
01_small_03.txt AC 2 ms 3728 KiB
01_small_04.txt AC 2 ms 3560 KiB
01_small_05.txt TLE 2208 ms 73872 KiB
01_small_06.txt TLE 2208 ms 73760 KiB
01_small_07.txt TLE 2208 ms 73736 KiB
02_random_00.txt AC 62 ms 73736 KiB
02_random_01.txt AC 56 ms 73676 KiB
02_random_02.txt AC 53 ms 73736 KiB
03_same_00.txt AC 55 ms 73740 KiB
03_same_01.txt AC 55 ms 73572 KiB
04_min_00.txt AC 52 ms 73680 KiB
04_min_01.txt TLE 2208 ms 73888 KiB
05_max_00.txt AC 54 ms 73492 KiB
05_max_01.txt TLE 2208 ms 73992 KiB
06_minmax_00.txt TLE 2208 ms 73880 KiB