結果

問題 No.1231 Make a Multiple of Ten
ユーザー onsen_manjuuuonsen_manjuuu
提出日時 2020-09-18 21:32:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 475 bytes
コンパイル時間 1,626 ms
コンパイル使用メモリ 168,280 KB
実行使用メモリ 17,128 KB
最終ジャッジ日時 2023-09-05 18:09:57
合計ジャッジ時間 2,998 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 46 ms
9,448 KB
testcase_05 AC 41 ms
8,600 KB
testcase_06 AC 17 ms
5,288 KB
testcase_07 AC 48 ms
9,888 KB
testcase_08 AC 19 ms
7,096 KB
testcase_09 AC 10 ms
4,552 KB
testcase_10 AC 43 ms
8,808 KB
testcase_11 AC 52 ms
10,132 KB
testcase_12 AC 93 ms
16,352 KB
testcase_13 AC 98 ms
17,128 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 98 ms
16,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
using ll = long long;
inline int ri() { int n; cin >> n; return n;}
const int INF = 1e9;

int main()
{
	int n; cin >> n;
	vector<vector<int>> dp(n + 1, vector<int>(10, -INF));
	dp[0][0] = 0;
	for(int i = 0; i < n; i++) {
		int t = ri() % 10;
		for(int j = 0; j < 10; j++) {
			dp[i + 1][(j + t) % 10] = max(dp[i][j] + 1, dp[i + 1][(j + t) % 10]);
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
		}
	}
	cout << dp[n][0] << endl;
}
0