結果

問題 No.1231 Make a Multiple of Ten
ユーザー CleyLCleyL
提出日時 2021-11-13 15:47:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 682 bytes
コンパイル時間 590 ms
コンパイル使用メモリ 70,160 KB
実行使用メモリ 11,620 KB
最終ジャッジ日時 2023-08-18 08:31:19
合計ジャッジ時間 3,506 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 40 ms
7,536 KB
testcase_05 AC 36 ms
7,472 KB
testcase_06 AC 15 ms
4,720 KB
testcase_07 AC 42 ms
7,592 KB
testcase_08 AC 16 ms
7,540 KB
testcase_09 AC 10 ms
4,380 KB
testcase_10 AC 38 ms
7,636 KB
testcase_11 AC 45 ms
7,448 KB
testcase_12 AC 82 ms
11,176 KB
testcase_13 AC 86 ms
11,612 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 86 ms
11,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int dp[200010][10];
int main(){
  int n;cin>>n;
  vector<int> A(n);
  for(int i = 0; n > i; i++){
    cin>>A[i];
  }

  
  for(int i = 0; n > i; i++){
    for(int j = 0; 10 > j; j++){
      dp[i][j] = -1;
    }
  }
  dp[0][0] = 0;
  for(int i = 1; n >= i; i++){
    for(int j = 0; 10 > j; j++){
      if(dp[i-1][j] == -1)continue;
      dp[i][(j+A[i-1])%10] = max(dp[i-1][j]+1,dp[i][(j+A[i-1])%10]);
      dp[i][j] = max(dp[i][j],dp[i-1][j]);
    }
  }
  // for(int i = 0; n >= i; i++){
  //   for(int j = 0; 10 > j; j++){
  //     cout << dp[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  cout << dp[n][0] << endl;
}
0