提出 #26480899
ソースコード 拡げる
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
template<int MOD> struct ModInt {
static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
int get() const { return (int)x; }
ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
return ModInt(u); }
bool operator==(ModInt that) const { return x == that.x; }
bool operator!=(ModInt that) const { return x != that.x; }
ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
typedef ModInt<998244353> mint;
/*---------------------------------------------------------------------------------------------------
∧_∧
∧_∧ (´<_` ) Welcome to My Coding Space!
( ´_ゝ`) / ⌒i @hamayanhamayan0
/ \ | |
/ / ̄ ̄ ̄ ̄/ |
__(__ニつ/ _/ .| .|____
\/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/
int N, a[3010], b[3010];
mint dp[3010][3010];
//---------------------------------------------------------------------------------------------------
void _main() {
cin >> N;
rep(i, 0, N) cin >> a[i];
rep(i, 0, N) cin >> b[i];
dp[0][0] = 1;
rep(i, 0, N) rep(nxt, a[i], b[i] + 1) {
rep(lst, 0, nxt + 1) dp[i + 1][nxt] += dp[i][lst];
}
mint ans = 0;
rep(lst, 0, 3001) ans += dp[N][lst];
cout << ans << endl;
}
提出情報
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
0 / 400 |
| 結果 |
|
|
| セット名 |
テストケース |
| 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 |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 00_sample_00.txt |
AC |
40 ms |
38936 KiB |
| 00_sample_01.txt |
AC |
37 ms |
38964 KiB |
| 00_sample_02.txt |
AC |
33 ms |
38840 KiB |
| 01_small_00.txt |
AC |
27 ms |
39004 KiB |
| 01_small_01.txt |
AC |
39 ms |
39004 KiB |
| 01_small_02.txt |
AC |
32 ms |
38972 KiB |
| 01_small_03.txt |
AC |
34 ms |
38872 KiB |
| 01_small_04.txt |
AC |
31 ms |
38968 KiB |
| 01_small_05.txt |
TLE |
2207 ms |
38736 KiB |
| 01_small_06.txt |
TLE |
2207 ms |
38660 KiB |
| 01_small_07.txt |
TLE |
2207 ms |
38608 KiB |
| 02_random_00.txt |
AC |
304 ms |
38956 KiB |
| 02_random_01.txt |
AC |
185 ms |
39016 KiB |
| 02_random_02.txt |
AC |
197 ms |
38856 KiB |
| 03_same_00.txt |
AC |
46 ms |
38944 KiB |
| 03_same_01.txt |
AC |
40 ms |
38892 KiB |
| 04_min_00.txt |
AC |
38 ms |
38960 KiB |
| 04_min_01.txt |
TLE |
2207 ms |
38616 KiB |
| 05_max_00.txt |
AC |
56 ms |
38868 KiB |
| 05_max_01.txt |
TLE |
2207 ms |
38720 KiB |
| 06_minmax_00.txt |
TLE |
2207 ms |
38640 KiB |