Submission #68598478


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#define rep(i, s, t) for(int i = (s); i <= (t); i ++)
#define per(i, s, t) for(int i = (s); i >= (t); i --)
template<typename T, typename T2>
inline void chmin(T &x, T2 &&y) { x = min(x, y); }
template<typename T, typename T2>
inline void chmax(T &x, T2 &&y) { x = max(x, y); }
typedef long long ll;

const int N = 5005, p = 998244353;
int n, a[N], b[N], l, r;
int sufa[N], preb[N];

int f[N][N], g[N][N];

int calc(int mn)
{
    memset(f, 0, sizeof f);
    memset(g, 0, sizeof g);
    
    f[0][0] = sufa[1] >= mn;
    rep(i, 0, n) g[0][i] = 1;

    rep(i, 1, n)
    {
        rep(j, 0, i - 1) if(sufa[i + 1] + preb[j] >= mn)
        {
            f[i][j] = g[i - 1][j];
        }

        g[i][0] = f[i][0];
        rep(j, 1, n) g[i][j] = (g[i][j - 1] + f[i][j]) % p;
    }
    // cerr << mn << " " << g[n][n] << endl;
    return g[n][n];
}

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    cin >> n >> l >> r;
    rep(i, 1, n) cin >> a[i];
    rep(i, 1, n) cin >> b[i];
    per(i, n, 1) sufa[i] = sufa[i + 1] + a[i];
    rep(i, 1, n) preb[i] = preb[i - 1] + b[i];
    cout << ((calc(preb[n] - r) - calc(preb[n] - (l - 1))) % p + p) % p;

    return 0;
}

Submission Info

Submission Time
Task A - Use Udon Coupon
User adam01
Language C++ 20 (gcc 12.2)
Score 700
Code Size 1261 Byte
Status AC
Exec Time 272 ms
Memory 199384 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 3
AC × 33
Set Name Test Cases
Sample 01-sample-01.txt, 01-sample-02.txt, 01-sample-03.txt
All 01-sample-01.txt, 01-sample-02.txt, 01-sample-03.txt, 02-large-random-01.txt, 02-large-random-02.txt, 02-large-random-03.txt, 02-large-random-04.txt, 02-large-random-05.txt, 02-large-random-06.txt, 02-large-random-07.txt, 02-large-random-08.txt, 02-large-random-09.txt, 02-large-random-10.txt, 03-small-random-01.txt, 03-small-random-02.txt, 03-small-random-03.txt, 03-small-random-04.txt, 03-small-random-05.txt, 03-small-random-06.txt, 03-small-random-07.txt, 03-small-random-08.txt, 03-small-random-09.txt, 03-small-random-10.txt, 04-large-random-2-01.txt, 04-large-random-2-02.txt, 04-large-random-2-03.txt, 04-large-random-2-04.txt, 04-large-random-2-05.txt, 05-large-random-small-range-01.txt, 05-large-random-small-range-02.txt, 05-large-random-small-range-03.txt, 05-large-random-small-range-04.txt, 05-large-random-small-range-05.txt
Case Name Status Exec Time Memory
01-sample-01.txt AC 93 ms 199244 KiB
01-sample-02.txt AC 93 ms 199192 KiB
01-sample-03.txt AC 95 ms 199324 KiB
02-large-random-01.txt AC 272 ms 199192 KiB
02-large-random-02.txt AC 269 ms 199240 KiB
02-large-random-03.txt AC 264 ms 199196 KiB
02-large-random-04.txt AC 259 ms 199256 KiB
02-large-random-05.txt AC 259 ms 199224 KiB
02-large-random-06.txt AC 259 ms 199132 KiB
02-large-random-07.txt AC 266 ms 199200 KiB
02-large-random-08.txt AC 261 ms 199252 KiB
02-large-random-09.txt AC 258 ms 199252 KiB
02-large-random-10.txt AC 258 ms 199240 KiB
03-small-random-01.txt AC 96 ms 199184 KiB
03-small-random-02.txt AC 96 ms 199188 KiB
03-small-random-03.txt AC 96 ms 199192 KiB
03-small-random-04.txt AC 96 ms 199128 KiB
03-small-random-05.txt AC 96 ms 199136 KiB
03-small-random-06.txt AC 98 ms 199184 KiB
03-small-random-07.txt AC 96 ms 199124 KiB
03-small-random-08.txt AC 95 ms 199124 KiB
03-small-random-09.txt AC 96 ms 199192 KiB
03-small-random-10.txt AC 96 ms 199176 KiB
04-large-random-2-01.txt AC 272 ms 199240 KiB
04-large-random-2-02.txt AC 265 ms 199308 KiB
04-large-random-2-03.txt AC 269 ms 199176 KiB
04-large-random-2-04.txt AC 263 ms 199196 KiB
04-large-random-2-05.txt AC 261 ms 199204 KiB
05-large-random-small-range-01.txt AC 271 ms 199192 KiB
05-large-random-small-range-02.txt AC 264 ms 199384 KiB
05-large-random-small-range-03.txt AC 263 ms 199168 KiB
05-large-random-small-range-04.txt AC 258 ms 199180 KiB
05-large-random-small-range-05.txt AC 254 ms 199168 KiB