結果

問題 No.1231 Make a Multiple of Ten
ユーザー YamaKasaYamaKasa
提出日時 2020-09-27 02:22:53
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 717 bytes
コンパイル時間 1,406 ms
コンパイル使用メモリ 165,932 KB
実行使用メモリ 15,300 KB
最終ジャッジ日時 2023-09-12 15:21:45
合計ジャッジ時間 6,560 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i] %= 10;
    }
    ll dp[N + 1][10];
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j < 10; j++) {
            dp[i][j] = -1;
        }
    }
    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 10; j++) {
            dp[i + 1][j] = dp[i][j];
        }
        for (int j = 0; j < N; j++) {
            if (dp[i][j] == -1) continue;
            int t = (j + A[i]) % 10;
            dp[i + 1][t] = max(dp[i + 1][t], dp[i][j] + 1);
        }
    }
    cout << dp[N][0] << "\n";
    return 0;
}
0