結果

問題 No.1825 Except One
ユーザー 沙耶花沙耶花
提出日時 2022-01-28 21:51:47
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 288 ms / 3,000 ms
コード長 890 bytes
コンパイル時間 5,826 ms
コンパイル使用メモリ 265,580 KB
実行使用メモリ 13,568 KB
最終ジャッジ日時 2023-08-30 11:06:21
合計ジャッジ時間 10,806 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
12,972 KB
testcase_01 AC 30 ms
12,908 KB
testcase_02 AC 40 ms
12,856 KB
testcase_03 AC 288 ms
13,568 KB
testcase_04 AC 197 ms
12,852 KB
testcase_05 AC 122 ms
13,288 KB
testcase_06 AC 56 ms
13,284 KB
testcase_07 AC 280 ms
13,276 KB
testcase_08 AC 278 ms
13,272 KB
testcase_09 AC 50 ms
12,900 KB
testcase_10 AC 232 ms
12,868 KB
testcase_11 AC 150 ms
12,844 KB
testcase_12 AC 203 ms
13,352 KB
testcase_13 AC 160 ms
12,972 KB
testcase_14 AC 24 ms
13,392 KB
testcase_15 AC 48 ms
13,344 KB
testcase_16 AC 45 ms
13,292 KB
testcase_17 AC 29 ms
12,900 KB
testcase_18 AC 24 ms
13,284 KB
testcase_19 AC 39 ms
12,972 KB
testcase_20 AC 41 ms
12,852 KB
testcase_21 AC 29 ms
12,852 KB
testcase_22 AC 34 ms
13,348 KB
testcase_23 AC 34 ms
13,284 KB
testcase_24 AC 140 ms
13,332 KB
testcase_25 AC 158 ms
12,860 KB
testcase_26 AC 71 ms
13,116 KB
testcase_27 AC 251 ms
12,996 KB
testcase_28 AC 285 ms
13,288 KB
testcase_29 AC 68 ms
13,276 KB
testcase_30 AC 72 ms
12,820 KB
testcase_31 AC 116 ms
12,940 KB
testcase_32 AC 280 ms
12,972 KB
testcase_33 AC 62 ms
12,804 KB
testcase_34 AC 279 ms
13,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define Inf 1000000001



int main(){
	
	int n;
	cin>>n;
	
	vector<int> a(n);
	rep(i,n)cin>>a[i];
	int S = 100 * 3;
	vector dp(S,vector(S,vector<long long>(3,0)));
	rep(i,S){
		dp[i][0][0] = 1;
	}
	
	rep(i,n){
		vector ndp(S,vector(S,vector<long long>(3,0)));
		rep(j,S){
			rep(k,S){
				rep(l,3){
					if(dp[j][k][l]==0)continue;
					ndp[j][k][l] += dp[j][k][l];
					int nj = j;
					int nk = k;
					int nl = min(2,l+1);
					if(a[i] - nj > 0 )continue;
					nk += abs(a[i]-j);
					if(nk > j)continue;
					ndp[nj][nk][nl] += dp[j][k][l];
				}
			}
		}
	//	cout<<i<<endl;
		swap(dp,ndp);
	}
	

	
	long long ans = 0;
	for(int i=0;i<S;i++)ans += dp[i][i][2];
	
	
	
	cout<<ans<<endl;
		
	
	
	return 0;
}
0