結果
問題 | No.979 Longest Divisor Sequence |
ユーザー | tenten |
提出日時 | 2020-08-25 10:23:46 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,241 bytes |
コンパイル時間 | 2,381 ms |
コンパイル使用メモリ | 79,892 KB |
実行使用メモリ | 65,452 KB |
最終ジャッジ日時 | 2024-04-24 04:14:55 |
合計ジャッジ時間 | 9,708 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 140 ms
41,368 KB |
testcase_01 | AC | 138 ms
41,360 KB |
testcase_02 | AC | 136 ms
41,508 KB |
testcase_03 | AC | 133 ms
41,520 KB |
testcase_04 | AC | 137 ms
41,336 KB |
testcase_05 | AC | 136 ms
41,508 KB |
testcase_06 | AC | 139 ms
41,664 KB |
testcase_07 | AC | 136 ms
41,508 KB |
testcase_08 | AC | 137 ms
41,212 KB |
testcase_09 | AC | 138 ms
41,216 KB |
testcase_10 | AC | 335 ms
48,320 KB |
testcase_11 | AC | 338 ms
48,256 KB |
testcase_12 | AC | 333 ms
46,232 KB |
testcase_13 | AC | 1,003 ms
57,616 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 > x / 2) { 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()); } }