結果

問題 No.1231 Make a Multiple of Ten
ユーザー yuuiyuui
提出日時 2020-09-18 21:45:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 598 bytes
コンパイル時間 2,310 ms
コンパイル使用メモリ 199,928 KB
実行使用メモリ 12,772 KB
最終ジャッジ日時 2023-09-04 10:20:13
合計ジャッジ時間 4,331 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 44 ms
10,780 KB
testcase_05 AC 37 ms
10,096 KB
testcase_06 AC 16 ms
7,588 KB
testcase_07 AC 46 ms
11,312 KB
testcase_08 AC 18 ms
9,680 KB
testcase_09 AC 11 ms
4,808 KB
testcase_10 AC 41 ms
10,312 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 2 ms
4,380 KB
testcase_15 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
ll dp[int(1e5) + 5][10];

int main() {
    ll N;
    cin >> N;
    vector<ll> a(N);
    rep(i, N) {
        cin >> a[i];
    }
    rep(i, N + 1) rep(j, 10) {
        dp[i][j] = -1;
    }
    dp[0][0] = 0;
    rep(i, N) rep(j, 10) {
        if (dp[i][j] == -1) {
            continue;
        }
        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);
    }
    cout << dp[N][0] << endl;

    return 0;
}
0