結果

問題 No.1231 Make a Multiple of Ten
ユーザー kotatsugamekotatsugame
提出日時 2020-09-18 21:29:45
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 313 bytes
コンパイル時間 521 ms
コンパイル使用メモリ 65,816 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 18:08:51
合計ジャッジ時間 1,805 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 37 ms
4,376 KB
testcase_05 AC 33 ms
4,380 KB
testcase_06 AC 14 ms
4,380 KB
testcase_07 AC 38 ms
4,380 KB
testcase_08 AC 13 ms
4,380 KB
testcase_09 AC 9 ms
4,380 KB
testcase_10 AC 34 ms
4,376 KB
testcase_11 AC 41 ms
4,376 KB
testcase_12 AC 75 ms
4,376 KB
testcase_13 AC 79 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 78 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int N;
int dp[10];
main()
{
	cin>>N;
	for(int i=1;i<10;i++)dp[i]=-1e9;
	for(int i=0;i<N;i++)
	{
		int A;cin>>A;
		int nxt[10];
		for(int j=0;j<10;j++)nxt[j]=dp[j];
		for(int j=0;j<10;j++)dp[(j+A)%10]=max(dp[(j+A)%10],nxt[j]+1);
	}
	cout<<dp[0]<<endl;
}
0