結果

問題 No.1231 Make a Multiple of Ten
ユーザー 🍮かんプリン
提出日時 2020-09-18 21:52:26
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 637 bytes
コンパイル時間 3,244 ms
コンパイル使用メモリ 161,612 KB
実行使用メモリ 17,280 KB
最終ジャッジ日時 2024-06-23 13:47:05
合計ジャッジ時間 2,683 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

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