結果

問題 No.1231 Make a Multiple of Ten
ユーザー karinohitokarinohito
提出日時 2021-09-06 00:05:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 563 bytes
コンパイル時間 1,553 ms
コンパイル使用メモリ 168,748 KB
実行使用メモリ 28,004 KB
最終ジャッジ日時 2023-08-24 05:31:31
合計ジャッジ時間 3,331 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 51 ms
14,476 KB
testcase_05 AC 45 ms
13,068 KB
testcase_06 AC 18 ms
7,292 KB
testcase_07 AC 54 ms
14,948 KB
testcase_08 AC 22 ms
9,968 KB
testcase_09 AC 12 ms
5,500 KB
testcase_10 AC 48 ms
13,668 KB
testcase_11 AC 57 ms
15,688 KB
testcase_12 AC 104 ms
26,732 KB
testcase_13 AC 109 ms
28,004 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 109 ms
27,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using Graph = vector<vector<ll>>;
ll mod=1e9+7;

int main() {
    ll N;
    cin>>N;
    vll A(N);
    rep(i,N)cin>>A[i];
    vector<vll> DP(N+1,vll(10,-1e18));
    DP[0][0]=0;
    rep(i,N){
        rep(j,10){
            DP[i+1][j]=max(DP[i][j],DP[i+1][j]);
            DP[i+1][(j+A[i])%10]=max(DP[i][j]+1,DP[i+1][(j+A[i])%10]);
        }
    }
    cout<<DP[N][0]<<endl;
}
0