結果
問題 |
No.1231 Make a Multiple of Ten
|
ユーザー |
![]() |
提出日時 | 2020-09-24 21:54:44 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 713 bytes |
コンパイル時間 | 2,537 ms |
コンパイル使用メモリ | 74,068 KB |
実行使用メモリ | 66,796 KB |
最終ジャッジ日時 | 2024-06-28 05:25:52 |
合計ジャッジ時間 | 6,812 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 1 TLE * 1 -- * 11 |
ソースコード
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); } }