結果

問題 No.1231 Make a Multiple of Ten
ユーザー YamaKasaYamaKasa
提出日時 2020-09-18 22:19:57
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 762 bytes
コンパイル時間 1,474 ms
コンパイル使用メモリ 165,180 KB
実行使用メモリ 12,088 KB
最終ジャッジ日時 2023-09-05 18:22:03
合計ジャッジ時間 2,916 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 41 ms
7,240 KB
testcase_05 AC 35 ms
6,892 KB
testcase_06 AC 16 ms
4,736 KB
testcase_07 AC 41 ms
7,624 KB
testcase_08 AC 15 ms
5,700 KB
testcase_09 AC 9 ms
4,380 KB
testcase_10 AC 36 ms
7,092 KB
testcase_11 AC 44 ms
7,848 KB
testcase_12 AC 79 ms
11,456 KB
testcase_13 AC 85 ms
12,088 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 84 ms
11,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    int A[N];
    int b[10]{};
    int s = 0;
    
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i] %= 10;
    }
    int d[N + 1][10]{};
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j < 10; j++) {
            d[i][j] = -1;
        }
    }
    d[0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 10; j++) {
            d[i + 1][j] = d[i][j];
        }
        for (int j = 0; j < 10; j++) {
            if (d[i][j] != -1) {
                int t = (j + A[i]) % 10;
                d[i + 1][t] = max(d[i + 1][t], d[i][j] + 1);
            }

        }
    }
    cout << d[N][0] << "\n";
    return 0;
}
0