結果

問題 No.1231 Make a Multiple of Ten
ユーザー MATSUMATMATSUMAT
提出日時 2019-03-20 22:43:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 485 bytes
コンパイル時間 1,501 ms
コンパイル使用メモリ 165,364 KB
実行使用メモリ 15,988 KB
最終ジャッジ日時 2023-09-05 18:07:18
合計ジャッジ時間 2,985 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 39 ms
9,028 KB
testcase_05 AC 35 ms
8,316 KB
testcase_06 AC 15 ms
5,316 KB
testcase_07 AC 42 ms
9,316 KB
testcase_08 AC 15 ms
7,008 KB
testcase_09 AC 10 ms
4,680 KB
testcase_10 AC 37 ms
8,660 KB
testcase_11 AC 44 ms
9,772 KB
testcase_12 AC 79 ms
15,400 KB
testcase_13 AC 84 ms
15,988 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 83 ms
15,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
    A[i]%=10;
  }
  int dp[N+5][15];
  for(int i=0;i<=N;i++){
    for(int j=0;j<=9;j++){
      dp[i][j] = -10000000;
    }
  }
  dp[0][0] = 0;
  for(int i=0;i<N;i++){
    for(int j=0;j<=9;j++){
      dp[i+1][j] = max(dp[i+1][j], dp[i][(10+j-A[i])%10]+1);
      dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
    }
  }
  cout << dp[N][0] << endl;
  return 0;
}
0