結果

問題 No.1231 Make a Multiple of Ten
ユーザー yuuiyuui
提出日時 2020-09-18 21:45:56
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 602 bytes
コンパイル時間 2,648 ms
コンパイル使用メモリ 201,016 KB
実行使用メモリ 20,252 KB
最終ジャッジ日時 2023-09-05 18:13:40
合計ジャッジ時間 3,469 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 43 ms
11,748 KB
testcase_05 AC 38 ms
11,804 KB
testcase_06 AC 16 ms
7,416 KB
testcase_07 AC 44 ms
12,132 KB
testcase_08 AC 17 ms
9,488 KB
testcase_09 AC 10 ms
4,884 KB
testcase_10 AC 40 ms
11,776 KB
testcase_11 AC 47 ms
12,360 KB
testcase_12 AC 86 ms
19,216 KB
testcase_13 AC 91 ms
20,060 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 90 ms
20,252 KB
権限があれば一括ダウンロードができます

ソースコード

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) * 2 + 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