結果
問題 | No.3009 異なる数字の最大の範囲(勉強会用) |
ユーザー | yuki2006 |
提出日時 | 2015-02-28 03:32:32 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,008 bytes |
コンパイル時間 | 5,497 ms |
コンパイル使用メモリ | 72,712 KB |
実行使用メモリ | 65,312 KB |
最終ジャッジ日時 | 2023-09-03 16:46:08 |
合計ジャッジ時間 | 28,740 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 133 ms
58,392 KB |
testcase_01 | AC | 133 ms
58,060 KB |
testcase_02 | AC | 132 ms
58,300 KB |
testcase_03 | AC | 131 ms
58,476 KB |
testcase_04 | AC | 128 ms
58,280 KB |
testcase_05 | AC | 130 ms
58,144 KB |
testcase_06 | AC | 125 ms
55,812 KB |
testcase_07 | AC | 129 ms
57,952 KB |
testcase_08 | AC | 129 ms
58,312 KB |
testcase_09 | AC | 128 ms
58,260 KB |
testcase_10 | AC | 127 ms
56,048 KB |
testcase_11 | AC | 131 ms
58,336 KB |
testcase_12 | AC | 130 ms
58,420 KB |
testcase_13 | AC | 130 ms
58,060 KB |
testcase_14 | AC | 130 ms
58,272 KB |
testcase_15 | AC | 4,801 ms
65,312 KB |
testcase_16 | AC | 4,369 ms
65,284 KB |
testcase_17 | AC | 4,684 ms
64,844 KB |
testcase_18 | TLE | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
ソースコード
import java.util.Scanner; public class Yuki3009_A { public Yuki3009_A() { Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); int[] data = new int[N]; for (int i = 0; i < N; i++) { data[i] = scanner.nextInt(); } int max = 0; //貪欲解 for (int L = 0; L < data.length; L++) { boolean[] checked = new boolean[1000000 + 1]; boolean allOK = true; for (int R = L; R < data.length; R++) { int c = data[R]; if (checked[c]) { max = Math.max(max, R - L); allOK = false; break; } checked[c] = true; } if (allOK) { max = Math.max(max, data.length - L); } } System.out.println(max); } public static void main(String[] args) { Yuki3009_A hoge = new Yuki3009_A(); } }