結果

問題 No.2625 Bouns Ai
ユーザー lemondolemondo
提出日時 2024-02-09 22:51:08
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 6,481 bytes
コンパイル時間 2,704 ms
コンパイル使用メモリ 298,344 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-09-28 16:01:29
合計ジャッジ時間 6,272 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#pragma region Macros
#include <bits/stdc++.h>
#include <immintrin.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfenv>
#include <cfloat>
#include <chrono>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdarg>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <streambuf>
#include <string>
#include <tuple>
#include <type_traits>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ll long long
#define OVERLOAD(e1, e2, e3, e4, NAME, ...) NAME
#define _rep1(i, n) for (long long i = 0; i < n; i++)
#define _rep2(i, a, b) for (long long i = a; i < b; ++i)
#define _rep3(i, a, b, t) \
for (long long i = a; i * (t / abs(t)) < b * (t / abs(t)); i += t)
#define rep(...) OVERLOAD(__VA_ARGS__, _rep3, _rep2, _rep1, _)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll) x.size()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pcnt __builtin_popcountll
#define SORT(v) sort(all(v))
#define UNIQUE(v) \
SORT(v); \
v.erase(unique(v.begin(), v.end()), v.end());
#define COPY(A, B) copy(all(A), B.begin());
#define REV(v) reverse(all(v))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#ifdef LOCAL
#define dbg(...) \
{ cout << __LINE__ << " : " << #__VA_ARGS__ << " = ", print(__VA_ARGS__); }
#else
#define dbg(...) true
#endif
using namespace std;
template <typename T>
using vc = vector<T>;
template <typename T>
using vvc = vector<vc<T>>;
template <typename T>
using vvvc = vector<vvc<T>>;
template <typename T, typename U>
bool chmin(T &k, U m) {
bool ret = k > m;
if (k > m) k = m;
return ret;
}
template <typename T, typename U>
bool chmax(T &k, U m) {
bool ret = k < m;
if (k < m) k = m;
return ret;
}
void print() { cout << "\n"; }
template <typename T>
inline void print(const vector<T> &v, string s = " ") {
for (ll i = 0; i < (ll)v.size(); i++)
cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");
}
template <typename T>
inline void print(const vvc<T> &v, string s = " ") {
for (ll i = 0; i < (ll)v.size(); i++) print(v[i], s);
}
template <typename T>
inline void print(const set<T> &vv) {
for (ll v : vv) cout << v << " ";
cout << "\n";
}
template <typename T>
inline void print(const multiset<T> &vv) {
for (ll v : vv) cout << v << " ";
cout << "\n";
}
template <typename T, typename S>
inline void print(const pair<T, S> &p) {
cout << p.first << " " << p.second << endl;
}
template <typename T, typename S>
inline void print(const vector<pair<T, S>> &v) {
for (auto &&p : v) print(p);
}
template <typename Head, typename... Tail>
void print(Head H, Tail... T) {
cout << H << " ";
print(T...);
}
template <typename T>
inline void print(const T &x) {
cout << x << "\n";
}
void yes(bool a) { cout << (a ? "yes" : "no") << endl; }
void YES(bool a) { cout << (a ? "YES" : "NO") << endl; }
void Yes(bool a) { cout << (a ? "Yes" : "No") << endl; }
template <typename T>
T SUM(vc<T> As) {
T ret = 0;
for (T a : As) ret += a;
return ret;
}
#pragma endregion
const ll INF = numeric_limits<long long>::max() / 2;
template <int mod>
struct ModInt {
int x;
ModInt() : x(0) {}
ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
ModInt &operator+=(const ModInt &p) {
if ((x += p.x) >= mod) x -= mod;
return *this;
}
ModInt &operator-=(const ModInt &p) {
if ((x += mod - p.x) >= mod) x -= mod;
return *this;
}
ModInt &operator*=(const ModInt &p) {
x = (int)(1LL * x * p.x % mod);
return *this;
}
ModInt &operator/=(const ModInt &p) {
*this *= p.inverse();
return *this;
}
ModInt operator-() const { return ModInt(-x); }
ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
bool operator==(const ModInt &p) const { return x == p.x; }
bool operator!=(const ModInt &p) const { return x != p.x; }
ModInt inverse() const {
int a = x, b = mod, u = 1, v = 0, t;
while (b > 0) {
t = a / b;
swap(a -= t * b, b);
swap(u -= t * v, v);
}
return ModInt(u);
}
ModInt pow(int64_t n) const {
ModInt ret(1), mul(x);
while (n > 0) {
if (n & 1) ret *= mul;
mul *= mul;
n >>= 1;
}
return ret;
}
friend ostream &operator<<(ostream &os, const ModInt &p) {
return os << p.x;
}
friend istream &operator>>(istream &is, ModInt &a) {
int64_t t;
is >> t;
a = ModInt<mod>(t);
return (is);
}
static int get_mod() { return mod; }
int val() const { return x; }
};
const int mod = 998244353;
using mint = ModInt<mod>;
void solve() {
ll N;
cin >> N;
vc<ll> As(N);
rep(i, N) cin >> As[i];
// i
vc<mint> dp(1e5 + 1), cums(1e5 + 1);
rep(i, 1e5 + 1) {
if (i >= As[0]) dp[i] = 1;
cums[i] = dp[i];
if (i) cums[i] += cums[i - 1];
}
rep(i, 1, N) {
vc<mint> ndp(1e5 + 1), ncums(1e5 + 1);
rep(j, 1e5 + 1) {
ll mini = min(j, j - As[i] + As[i - 1]);
if (mini >= 0) ndp[j] += cums[mini];
}
rep(j, 1e5 + 1) {
ncums[j] = ndp[j];
if (j) ncums[j] += ncums[j - 1];
}
swap(dp, ndp);
swap(cums, ncums);
}
print(cums[1e5]);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(15);
// ll T; cin >> T;
// rep(_, T)
solve();
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0