結果

問題 No.1231 Make a Multiple of Ten
ユーザー 37zigen
提出日時 2020-09-23 04:30:59
言語 Java
(openjdk 23)
結果
AC  
実行時間 886 ms / 2,000 ms
コード長 627 bytes
コンパイル時間 2,644 ms
コンパイル使用メモリ 75,924 KB
実行使用メモリ 54,236 KB
最終ジャッジ日時 2024-06-27 06:15:40
合計ジャッジ時間 11,128 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

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