結果
| 問題 |
No.1231 Make a Multiple of Ten
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-09-18 23:50:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 107 ms / 2,000 ms |
| コード長 | 738 bytes |
| コンパイル時間 | 1,802 ms |
| コンパイル使用メモリ | 198,032 KB |
| 最終ジャッジ日時 | 2025-01-14 18:03:15 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
#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;
}