結果

問題 No.1231 Make a Multiple of Ten
ユーザー 37zigen37zigen
提出日時 2020-09-23 04:30:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 789 ms / 2,000 ms
コード長 627 bytes
コンパイル時間 2,017 ms
コンパイル使用メモリ 72,388 KB
実行使用メモリ 66,640 KB
最終ジャッジ日時 2023-09-09 13:16:40
合計ジャッジ時間 10,210 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,260 KB
testcase_01 AC 120 ms
55,552 KB
testcase_02 AC 121 ms
55,568 KB
testcase_03 AC 121 ms
55,904 KB
testcase_04 AC 568 ms
61,600 KB
testcase_05 AC 551 ms
61,452 KB
testcase_06 AC 398 ms
60,172 KB
testcase_07 AC 597 ms
61,148 KB
testcase_08 AC 405 ms
61,080 KB
testcase_09 AC 321 ms
60,372 KB
testcase_10 AC 588 ms
61,060 KB
testcase_11 AC 579 ms
61,348 KB
testcase_12 AC 717 ms
64,420 KB
testcase_13 AC 767 ms
66,640 KB
testcase_14 AC 122 ms
55,632 KB
testcase_15 AC 789 ms
65,080 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-10);
		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