結果

問題 No.1378 Flattening
ユーザー leaf_1415leaf_1415
提出日時 2020-10-14 19:40:28
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 638 bytes
コンパイル時間 1,197 ms
コンパイル使用メモリ 61,712 KB
実行使用メモリ 199,200 KB
最終ジャッジ日時 2023-09-28 00:49:26
合計ジャッジ時間 10,120 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 WA -
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 340 ms
199,052 KB
testcase_32 AC 331 ms
198,992 KB
testcase_33 AC 325 ms
199,024 KB
testcase_34 AC 333 ms
199,016 KB
testcase_35 AC 330 ms
199,044 KB
testcase_36 AC 353 ms
198,996 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cassert>
#include <algorithm>
#define llint long long
#define mod 998244353

using namespace std;

llint n;
llint a[5005], b[5005];
llint dp[5005][5005];

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	assert(n >= 1 && n <= 5000);
	for(int i = 1; i <= n; i++) b[i] = a[i];
	sort(b+1, b+n+1);
	for(int i = 1; i <= n; i++) assert(b[i] == i);
	
	dp[0][1] = 1;
	for(int i = 0; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(i+1 <= n && a[i+1] >= a[j]) (dp[i+1][j] += dp[i][j]) %= mod;
			if(j+1 <= n) (dp[i][j+1] += dp[i][j]) %= mod;
		}
	}
	cout << dp[n][n] << endl;
	
	return 0;
}
0