結果
問題 | No.979 Longest Divisor Sequence |
ユーザー | tenten |
提出日時 | 2020-08-25 10:22:13 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,241 bytes |
コンパイル時間 | 2,043 ms |
コンパイル使用メモリ | 80,240 KB |
実行使用メモリ | 64,224 KB |
最終ジャッジ日時 | 2024-04-24 04:14:45 |
合計ジャッジ時間 | 8,915 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 110 ms
46,836 KB |
testcase_01 | AC | 107 ms
41,396 KB |
testcase_02 | AC | 100 ms
40,060 KB |
testcase_03 | AC | 112 ms
41,176 KB |
testcase_04 | AC | 107 ms
41,072 KB |
testcase_05 | AC | 103 ms
40,336 KB |
testcase_06 | AC | 101 ms
40,280 KB |
testcase_07 | AC | 99 ms
40,296 KB |
testcase_08 | AC | 109 ms
41,256 KB |
testcase_09 | AC | 110 ms
41,088 KB |
testcase_10 | AC | 341 ms
46,412 KB |
testcase_11 | AC | 316 ms
45,620 KB |
testcase_12 | AC | 342 ms
45,504 KB |
testcase_13 | AC | 847 ms
57,940 KB |
testcase_14 | TLE | - |
testcase_15 | -- | - |
ソースコード
import java.util.*; public class Main { static final int MOD = 1000000007; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); ArrayList<TreeSet<Integer>> list = new ArrayList<>(); list.add(new TreeSet<>()); list.get(0).add(sc.nextInt()); for (int i = 1; i < n; i++) { int x = sc.nextInt(); int left = -1; int right = list.size(); while (right - left > 1) { int m = (left + right) / 2; boolean exist = false; for (int y : list.get(m)) { if (y / 2 > x) { break; } if (x % y == 0 && x > y) { exist = true; break; } } if (exist) { left = m; } else { right = m; } } if (left == list.size() - 1) { list.add(new TreeSet<>()); } list.get(left + 1).add(x); } System.out.println(list.size()); } }