結果

問題 No.1231 Make a Multiple of Ten
ユーザー face4face4
提出日時 2020-09-22 09:49:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 534 bytes
コンパイル時間 493 ms
コンパイル使用メモリ 68,844 KB
実行使用メモリ 11,940 KB
最終ジャッジ日時 2023-09-08 03:12:00
合計ジャッジ時間 1,957 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 42 ms
7,264 KB
testcase_05 AC 33 ms
6,736 KB
testcase_06 AC 14 ms
4,644 KB
testcase_07 AC 39 ms
7,452 KB
testcase_08 AC 15 ms
5,716 KB
testcase_09 AC 10 ms
4,380 KB
testcase_10 AC 35 ms
6,932 KB
testcase_11 AC 42 ms
7,724 KB
testcase_12 AC 78 ms
11,480 KB
testcase_13 AC 81 ms
11,864 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 84 ms
11,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstring>
using namespace std;

int main(){
    int n;
    cin >> n;
    int x[n];
    for(int i = 0; i < n; i++)  cin >> x[i];
    int dp[n+1][10];
    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 10; j++){
            if(dp[i][j] != -1)  dp[i+1][(j+x[i])%10] = max(dp[i+1][(j+x[i])%10], dp[i][j]+1);
        }
        for(int j = 0; j < 10; j++) dp[i+1][j] = max(dp[i][j], dp[i+1][j]);
    }
    cout << max(0, dp[n][0]) << endl;
    return 0;
}
0