結果

問題 No.1231 Make a Multiple of Ten
ユーザー GetDigit()GetDigit()
提出日時 2022-11-03 09:01:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 658 bytes
コンパイル時間 1,500 ms
コンパイル使用メモリ 164,556 KB
実行使用メモリ 12,156 KB
最終ジャッジ日時 2023-09-24 18:48:33
合計ジャッジ時間 2,852 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 18 ms
7,428 KB
testcase_05 AC 16 ms
7,028 KB
testcase_06 AC 8 ms
4,852 KB
testcase_07 AC 19 ms
7,640 KB
testcase_08 AC 10 ms
5,868 KB
testcase_09 AC 5 ms
4,380 KB
testcase_10 AC 17 ms
7,124 KB
testcase_11 AC 19 ms
7,884 KB
testcase_12 AC 34 ms
11,640 KB
testcase_13 AC 35 ms
12,064 KB
testcase_14 WA -
testcase_15 AC 35 ms
12,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <vector>
using namespace std;

int max(int a,int b){
    if(a>b){
        return a;
    }
    return b;
}

int main(){
    int N;
    scanf("%d",&N);
    int a[N];
    for(int i=0;i<N;i++){
        scanf("%d",&a[i]);
        a[i] = a[i] % 10;
    }
    int dp[N][10] = {};
    for(int i=0;i<10;i++){
    	if(i < a[0]){
    		dp[0][i] = 0;
    	}
    	if(i == a[0]){
    		dp[0][i] = 1;
    	}
    	if(i > a[0]){
    		dp[0][i] = -2147483648;
    	}
    }
    for(int i=1;i<N;i++){
        for(int j=0;j<10;j++){
            dp[i][j] = max(dp[i-1][j],dp[i-1][(10+j-a[i])%10]+1);
        }
    }
    printf("%d",dp[N-1][0]);
}
0