結果

問題 No.1231 Make a Multiple of Ten
ユーザー pengin_2000pengin_2000
提出日時 2020-09-18 21:38:57
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 490 bytes
コンパイル時間 840 ms
コンパイル使用メモリ 29,152 KB
実行使用メモリ 10,412 KB
最終ジャッジ日時 2023-09-05 18:11:32
合計ジャッジ時間 1,807 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 19 ms
7,092 KB
testcase_05 AC 15 ms
6,160 KB
testcase_06 AC 7 ms
4,376 KB
testcase_07 AC 19 ms
6,360 KB
testcase_08 AC 9 ms
4,380 KB
testcase_09 AC 4 ms
4,376 KB
testcase_10 AC 17 ms
6,104 KB
testcase_11 AC 20 ms
6,680 KB
testcase_12 AC 37 ms
10,044 KB
testcase_13 AC 37 ms
10,412 KB
testcase_14 AC 0 ms
4,376 KB
testcase_15 AC 38 ms
10,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i, j;
	int a[200005];
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	int dp[200005][10];
	for (j = 0; j < 10; j++)
		dp[0][j] = 0;
	dp[0][a[0] % 10] = 1;
	for (i = 1; i < n; i++)
	{
		for (j = 0; j < 10; j++)
			dp[i][j] = dp[i - 1][j];
		for (j = 0; j < 10; j++)
			if (dp[i - 1][j] > 0 && dp[i][(j + a[i]) % 10] < dp[i - 1][j] + 1)
				dp[i][(j + a[i]) % 10] = dp[i - 1][j] + 1;
	}
	printf("%d\n", dp[n - 1][0]);
	return 0;
}
0