結果

問題 No.1231 Make a Multiple of Ten
ユーザー abc3abc3
提出日時 2020-09-18 23:50:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 738 bytes
コンパイル時間 2,174 ms
コンパイル使用メモリ 204,724 KB
実行使用メモリ 18,608 KB
最終ジャッジ日時 2023-09-05 18:24:13
合計ジャッジ時間 3,810 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 48 ms
10,072 KB
testcase_05 AC 43 ms
9,300 KB
testcase_06 AC 18 ms
5,368 KB
testcase_07 AC 51 ms
10,388 KB
testcase_08 AC 21 ms
7,232 KB
testcase_09 AC 11 ms
4,380 KB
testcase_10 AC 46 ms
9,760 KB
testcase_11 AC 53 ms
10,916 KB
testcase_12 AC 98 ms
17,816 KB
testcase_13 AC 103 ms
18,560 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 102 ms
18,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  vector<vector<int>>dp(N+1,vector<int>(10,-1));
  dp[0][0]=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<=9;j++){
      if(dp[i][j]==-1){continue;}
      chmax(dp[i+1][(j+A[i])%10],dp[i][j]+1);//最大の枚数=dpの値
      chmax(dp[i+1][j],dp[i][j]);
    }
  }
  cout<<dp[N][0]<<endl;
  return 0;                       
}
0