結果

問題 No.1231 Make a Multiple of Ten
ユーザー Example0911Example0911
提出日時 2020-09-18 21:41:20
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 695 bytes
コンパイル時間 1,642 ms
コンパイル使用メモリ 167,228 KB
実行使用メモリ 20,308 KB
最終ジャッジ日時 2023-09-05 18:12:08
合計ジャッジ時間 3,152 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
18,972 KB
testcase_01 AC 8 ms
18,996 KB
testcase_02 AC 8 ms
19,044 KB
testcase_03 AC 7 ms
19,188 KB
testcase_04 AC 45 ms
19,256 KB
testcase_05 AC 40 ms
19,256 KB
testcase_06 AC 21 ms
19,140 KB
testcase_07 AC 47 ms
19,204 KB
testcase_08 AC 20 ms
19,076 KB
testcase_09 AC 15 ms
18,960 KB
testcase_10 AC 43 ms
19,200 KB
testcase_11 AC 49 ms
19,604 KB
testcase_12 AC 86 ms
20,024 KB
testcase_13 AC 89 ms
20,308 KB
testcase_14 AC 8 ms
19,040 KB
testcase_15 AC 90 ms
20,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

//#define int long long
#define ll long long

ll INF = (1LL << 60);
int mod = 1000000007;

using P = pair<int, int>;
ll dp[200010][10];
signed main() {
	int N; cin >> N;
	vector<ll>A(N); for (int i = 0; i < N; i++)cin >> A[i];
	for (int i = 0; i < 200010; i++) {
		for (int j = 0; j < 10; j++) {
			dp[i][j] = -INF;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++) {
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);

			dp[i + 1][(j + A[i]) % 10] = max(dp[i + 1][(j + A[i]) % 10], dp[i][j] + 1);
		
		}
	}
	ll ans = dp[N][0];
	cout << ans << endl;
	return 0;
}
0