結果

問題 No.1231 Make a Multiple of Ten
ユーザー kyuridenamidakyuridenamida
提出日時 2020-09-18 22:00:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 517 bytes
コンパイル時間 1,439 ms
コンパイル使用メモリ 164,148 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 18:19:23
合計ジャッジ時間 2,888 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;


int main() {
    long long dp[10] = {};
    for (int i = 0; i < 10; i++) dp[i] = -1e18;

    dp[0] = 0;

    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        long long ndp[10];
        memcpy(ndp, dp, sizeof(ndp));
        long long x;
        cin >> x;
        for (int j = 0; j < 10; j++)
            ndp[(j + x) % 10] = max(ndp[(j + x) % 10], dp[j] + 1);
        memcpy(dp, ndp, sizeof(ndp));
    }
    cout << dp[0] << endl;

}
0