結果

問題 No.1231 Make a Multiple of Ten
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2020-09-18 21:52:26
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 637 bytes
コンパイル時間 1,247 ms
コンパイル使用メモリ 147,468 KB
実行使用メモリ 17,088 KB
最終ジャッジ日時 2023-09-05 18:18:19
合計ジャッジ時間 2,912 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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,376 KB
testcase_04 AC 47 ms
9,428 KB
testcase_05 AC 41 ms
8,864 KB
testcase_06 AC 18 ms
5,076 KB
testcase_07 AC 49 ms
9,620 KB
testcase_08 AC 20 ms
7,144 KB
testcase_09 AC 11 ms
4,620 KB
testcase_10 AC 44 ms
8,840 KB
testcase_11 AC 52 ms
10,124 KB
testcase_12 AC 95 ms
16,512 KB
testcase_13 AC 99 ms
17,088 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 100 ms
17,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *   @FileName	b.cpp
 *   @Author	kanpurin
 *   @Created	2020.09.18 21:52:23
**/

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

int main() {
    int n;cin >> n;
    constexpr int INF = 1e9 + 6;
    vector<vector<int>> dp(n+1,vector<int>(10,-INF));
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        int a;cin >> a;
        for (int j = 0; j < 10; j++) {
            dp[i + 1][(j + a) % 10] = dp[i][(j + a) % 10];
            if (dp[i][j] == -INF) continue;
            dp[i + 1][(j + a) % 10] = max(dp[i + 1][(j + a) % 10],dp[i][j] + 1);
        }
    }
    cout << dp[n][0] << endl;
    return 0;
}
0