結果

問題 No.1231 Make a Multiple of Ten
ユーザー ha71ha71
提出日時 2020-09-20 16:19:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 673 bytes
コンパイル時間 1,477 ms
コンパイル使用メモリ 166,100 KB
実行使用メモリ 12,644 KB
最終ジャッジ日時 2023-09-06 16:21:43
合計ジャッジ時間 3,162 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
11,280 KB
testcase_01 AC 4 ms
11,072 KB
testcase_02 AC 4 ms
11,132 KB
testcase_03 AC 5 ms
11,084 KB
testcase_04 AC 42 ms
11,832 KB
testcase_05 AC 37 ms
11,748 KB
testcase_06 AC 17 ms
11,320 KB
testcase_07 AC 43 ms
11,820 KB
testcase_08 AC 17 ms
11,508 KB
testcase_09 AC 12 ms
11,220 KB
testcase_10 AC 39 ms
11,740 KB
testcase_11 AC 46 ms
12,052 KB
testcase_12 AC 81 ms
12,600 KB
testcase_13 AC 85 ms
12,636 KB
testcase_14 AC 5 ms
11,124 KB
testcase_15 AC 85 ms
12,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include "atcoder/all"
typedef long long int ll;
using namespace std;
// using namespace atcoder;
#define MAXN 200005
int dp[MAXN][10];
int main() {
    int n;
    cin >> n;
    ll a[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < MAXN; i++) {
        for (int j = 0; j < 10; j++) {
            dp[i][j] = -1000;
        } 
    }
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 10; j++) {
            dp[i][(j + a[i]) % 10] = max(dp[i - 1][j] + 1, max(dp[i - 1][(j + a[i]) % 10], dp[i][(j + a[i]) % 10]));
        }
    }
    cout << dp[n][0] << endl;
    return 0;
}
0