結果

問題 No.2625 Bouns Ai
ユーザー TairitsuMeowTairitsuMeow
提出日時 2024-02-09 22:25:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 1,168 bytes
コンパイル時間 1,557 ms
コンパイル使用メモリ 168,288 KB
実行使用メモリ 321,764 KB
最終ジャッジ日時 2024-02-09 22:25:41
合計ジャッジ時間 5,476 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
10,468 KB
testcase_01 AC 3 ms
10,468 KB
testcase_02 AC 10 ms
22,756 KB
testcase_03 AC 111 ms
162,444 KB
testcase_04 AC 171 ms
242,148 KB
testcase_05 AC 119 ms
162,496 KB
testcase_06 AC 106 ms
162,500 KB
testcase_07 AC 107 ms
162,496 KB
testcase_08 AC 108 ms
162,556 KB
testcase_09 AC 107 ms
162,444 KB
testcase_10 AC 172 ms
242,020 KB
testcase_11 AC 6 ms
14,564 KB
testcase_12 AC 173 ms
242,148 KB
testcase_13 AC 175 ms
241,252 KB
testcase_14 AC 174 ms
241,892 KB
testcase_15 AC 192 ms
241,892 KB
testcase_16 AC 166 ms
295,652 KB
testcase_17 AC 167 ms
296,932 KB
testcase_18 AC 173 ms
297,060 KB
testcase_19 AC 173 ms
321,764 KB
testcase_20 AC 159 ms
321,764 KB
testcase_21 AC 161 ms
321,764 KB
testcase_22 AC 170 ms
320,480 KB
testcase_23 AC 171 ms
320,492 KB
testcase_24 AC 162 ms
321,764 KB
testcase_25 AC 160 ms
320,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// Problem: No.2625 Bouns Ai
// Contest: yukicoder
// URL: https://yukicoder.me/problems/no/2625
// Memory Limit: 512 MB
// Time Limit: 2000 ms

#include<bits/stdc++.h>
#define debug(x) cerr<<(#x)<<" "<<(x)<<endl
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<ll,ll>
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define per(i,a,b) for(ll i=(a);i>=(b);--i)
using namespace std;
bool Mbe; 
ll read(){
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
const ll N=2e5+9,V=1e5,Mod=998244353;
ll n,a[N],dp[205][N],sum[N];
bool Med;
int main(){
	cerr<<fabs(&Med-&Mbe)/1048576.0<<"MB\n";
	n=read();
	rep(i,1,n)a[i]=read();
	rep(i,0,V-a[i])dp[1][i]=1;
	sum[0]=dp[1][0];
	rep(j,1,V)sum[j]=(sum[j-1]+dp[1][j])%Mod;
	rep(i,2,n){
		//k<=a[i]+j-a[i-1]
		rep(j,0,V-a[i]){
			ll k=a[i]+j-a[i-1];
			k=min(k,V);
			if(k>=0)dp[i][j]=sum[min(j,k)];
		}
		sum[0]=dp[i][0];
		rep(j,1,V)sum[j]=(sum[j-1]+dp[i][j])%Mod;
	}
	write(sum[V]);
	return 0;
}
0