結果

問題 No.1231 Make a Multiple of Ten
ユーザー 37zigen37zigen
提出日時 2020-09-23 04:33:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 756 ms / 2,000 ms
コード長 624 bytes
コンパイル時間 1,983 ms
コンパイル使用メモリ 72,632 KB
実行使用メモリ 65,264 KB
最終ジャッジ日時 2023-09-09 13:20:19
合計ジャッジ時間 10,718 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,940 KB
testcase_01 AC 120 ms
56,436 KB
testcase_02 AC 120 ms
57,940 KB
testcase_03 AC 120 ms
56,140 KB
testcase_04 AC 543 ms
61,636 KB
testcase_05 AC 556 ms
59,744 KB
testcase_06 AC 396 ms
60,184 KB
testcase_07 AC 590 ms
62,308 KB
testcase_08 AC 400 ms
60,904 KB
testcase_09 AC 312 ms
60,168 KB
testcase_10 AC 586 ms
61,748 KB
testcase_11 AC 564 ms
61,384 KB
testcase_12 AC 723 ms
63,372 KB
testcase_13 AC 756 ms
65,180 KB
testcase_14 AC 120 ms
56,556 KB
testcase_15 AC 743 ms
65,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;

class Main {
	public static void main(String[] $) {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[] dp=new int[10];
		Arrays.fill(dp, -N);
		dp[0]=0;
		for (int i=0;i<N;++i) {
			int a=sc.nextInt()%10;
			int[] ndp=Arrays.copyOf(dp, dp.length);
			for (int j=0;j<10;++j) {
				ndp[(j+a)%10]=Math.max(ndp[(j+a)%10], dp[j]+1);
			}
			dp=ndp;
		}
		System.out.println(dp[0]);
		
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}
0