結果
問題 | No.2625 Bouns Ai |
ユーザー |
![]() |
提出日時 | 2024-02-09 22:41:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,172 bytes |
コンパイル時間 | 4,077 ms |
コンパイル使用メモリ | 253,024 KB |
最終ジャッジ日時 | 2025-02-19 03:56:48 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 23 |
ソースコード
#include<bits/stdc++.h>#include<atcoder/all>using namespace atcoder;using mint=modint998244353;using namespace std;using ll=long long;using ull=unsigned long long;#define rep(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)#define rrep(i,a,b) for(ll i=(ll)(a-1);i>=(ll)(b);i--)#define MOD 998244353//#define MOD 1000000007#define INF 1e18#define Pair pair<ll,ll>//#define PI numbers::pi//#define E numbers::etemplate <typename T> bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}template <typename T> bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}ll dx[4]={0,1,0,-1};ll dy[4]={1,0,-1,0};int main(){ll n; cin >> n;vector<ll> a(n);rep(i,0,n) cin >> a[i];vector<vector<ll>> dp(n,vector<ll>(100001,0));rep(i,a[0],100001) dp[0][i]=1;vector<ll> sum(100001,0);sum[0]=dp[0][0];rep(i,1,100001) sum[i]=(sum[i-1]+dp[0][i])%MOD;if(n>2){rep(i,1,n){rep(j,a[i],100001){ll x=j-a[i];dp[i][j]=sum[min(j,x+a[i-1])];}sum[0]=dp[i][0];rep(j,1,100001) sum[j]=(sum[j-1]+dp[i][j])%MOD;}}cout << sum[100000] << endl;}