結果

問題 No.1231 Make a Multiple of Ten
ユーザー Ren SuzugamoriRen Suzugamori
提出日時 2020-09-23 11:44:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 575 bytes
コンパイル時間 1,605 ms
コンパイル使用メモリ 165,532 KB
実行使用メモリ 20,624 KB
最終ジャッジ日時 2023-09-10 01:39:27
合計ジャッジ時間 3,238 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
19,168 KB
testcase_01 AC 7 ms
18,956 KB
testcase_02 AC 7 ms
18,944 KB
testcase_03 AC 7 ms
18,944 KB
testcase_04 AC 44 ms
19,708 KB
testcase_05 AC 39 ms
19,620 KB
testcase_06 AC 20 ms
19,188 KB
testcase_07 AC 45 ms
19,736 KB
testcase_08 AC 20 ms
19,404 KB
testcase_09 AC 15 ms
19,224 KB
testcase_10 AC 42 ms
19,748 KB
testcase_11 AC 48 ms
19,860 KB
testcase_12 AC 83 ms
20,624 KB
testcase_13 AC 87 ms
20,500 KB
testcase_14 AC 7 ms
19,012 KB
testcase_15 AC 87 ms
20,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=2e5+1;
int d[maxn][10];
signed main()
{
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<=maxn;i++)
    {
        for(int j=0;j<=9;j++)
        {
            d[i][j]=INT_MIN;
        }
    }
    d[0][0]=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=9;j++)
        {
            int k = j + a[i];
            d[i][k % 10] = max(d[i][k%10], max(d[i - 1][k % 10], d[i - 1][j] + 1));
        }
    }
    cout<<d[n][0];
	exit(0);
}
0