結果

問題 No.1682 Unfair Game
ユーザー 👑 ygussanyygussany
提出日時 2021-08-15 13:01:54
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 865 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 29,928 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-12 06:22:48
合計ジャッジ時間 1,468 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 0 ms
4,380 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

const int Mod = 1000000007;

int main()
{
	int i, N, P[101];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(P[i]));
	
	int j, k, cur, prev, dp[2][101][2] = {};
	for (i = 1, cur = 1, prev = 0, dp[0][0][0] = 1; i <= N; i++, cur ^= 1, prev ^= 1) {
		for (j = 0, dp[cur][0][0] = 0, dp[cur][0][1] = 0; j < i; j++) {
			dp[cur][j][0] += dp[prev][j][0];
			if (dp[cur][j][0] >= Mod) dp[cur][j][0] -= Mod;
			dp[cur][j][1] += dp[prev][j][1];
			if (dp[cur][j][1] >= Mod) dp[cur][j][1] -= Mod;
			
			if (P[i] > 50) {
				dp[cur][j+1][0] = dp[prev][j][1];
				dp[cur][j+1][1] = dp[prev][j][0];
			} else if (P[i] < 50) {
				dp[cur][j+1][0] = dp[prev][j][0];
				dp[cur][j+1][1] = dp[prev][j][1];
			}
		}
	}
	
	long long ans = 0;
	for (j = 1; j <= i; j++) ans += dp[prev][j][1-j%2];
	printf("%lld\n", ans % Mod);
	fflush(stdout);
	return 0;
}
0