結果

問題 No.1231 Make a Multiple of Ten
ユーザー furafura
提出日時 2020-09-19 18:11:26
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 400 bytes
コンパイル時間 2,084 ms
コンパイル使用メモリ 202,864 KB
実行使用メモリ 18,128 KB
最終ジャッジ日時 2023-09-05 22:50:52
合計ジャッジ時間 3,404 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 24 ms
10,016 KB
testcase_05 AC 21 ms
9,188 KB
testcase_06 AC 10 ms
5,420 KB
testcase_07 AC 26 ms
10,108 KB
testcase_08 AC 13 ms
7,268 KB
testcase_09 AC 6 ms
4,436 KB
testcase_10 AC 23 ms
9,520 KB
testcase_11 AC 26 ms
10,620 KB
testcase_12 AC 48 ms
17,452 KB
testcase_13 AC 50 ms
17,884 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 51 ms
18,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const int INF=1<<29;

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	vector dp(n+1,vector(10,-INF));
	dp[0][0]=0;
	rep(i,n){
		rep(d,10) dp[i+1][d]=dp[i][d];
		rep(d,10) dp[i+1][(d+a[i])%10]=max(dp[i+1][(d+a[i])%10],dp[i][d]+1);
	}
	printf("%d\n",dp[n][0]);

	return 0;
}
0