結果

問題 No.1231 Make a Multiple of Ten
ユーザー tentententen
提出日時 2020-09-24 21:54:44
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 713 bytes
コンパイル時間 3,452 ms
コンパイル使用メモリ 78,732 KB
実行使用メモリ 70,692 KB
最終ジャッジ日時 2023-09-10 13:58:40
合計ジャッジ時間 8,080 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
60,192 KB
testcase_01 AC 124 ms
55,596 KB
testcase_02 AC 123 ms
55,920 KB
testcase_03 AC 123 ms
56,048 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	boolean[][] exists = new boolean[n + 1][10];
    	exists[0][0] = true;
    	int max = 0;
    	for (int i = 1; i <= n; i++) {
    	    int x = sc.nextInt() % 10;
    	    for (int j = i - 1; j >= 0 && j + 1 + (n - i + 1) > max; j--) {
    	        for (int k = 0; k < 10; k++) {
    	            if (exists[j][k]) {
    	                exists[j + 1][(k + x) % 10] = true;
    	            }
    	        }
    	        if (exists[j + 1][0]) {
    	            max = Math.max(max, j + 1);
    	        }
    	    }
    	}
    	System.out.println(max);
	}
}
0