結果

問題 No.1231 Make a Multiple of Ten
ユーザー umezoumezo
提出日時 2020-09-18 23:00:29
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 530 bytes
コンパイル時間 2,474 ms
コンパイル使用メモリ 201,116 KB
実行使用メモリ 12,232 KB
最終ジャッジ日時 2023-09-05 18:23:43
合計ジャッジ時間 3,335 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 38 ms
7,504 KB
testcase_05 AC 35 ms
7,540 KB
testcase_06 AC 14 ms
4,760 KB
testcase_07 AC 40 ms
7,448 KB
testcase_08 AC 16 ms
7,476 KB
testcase_09 AC 10 ms
4,380 KB
testcase_10 AC 37 ms
7,456 KB
testcase_11 AC 43 ms
7,524 KB
testcase_12 AC 78 ms
12,064 KB
testcase_13 AC 82 ms
12,020 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 82 ms
12,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int dp[2000020][10];

int main(){
  int n;
  cin>>n;
  
  vector<int> A(n+1);
  rep(i,n){
    int x;
    cin>>x;
    A[i+1]=x%10;
  }
  
  dp[1][A[1]]=1;
  for(int i=1;i<n;i++){
    for(int j=0;j<=9;j++){
      if(dp[i][(j-A[i+1]+10)%10]==0 && dp[i][j]==0) continue;
      dp[i+1][j]=max(dp[i][j],dp[i][(j-A[i+1]+10)%10]+1);
    }
  }
  cout<<dp[n][0]<<endl;

  return 0;
}
0