結果
問題 |
No.979 Longest Divisor Sequence
|
ユーザー |
![]() |
提出日時 | 2020-08-25 10:22:13 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,241 bytes |
コンパイル時間 | 3,132 ms |
コンパイル使用メモリ | 79,668 KB |
実行使用メモリ | 77,088 KB |
最終ジャッジ日時 | 2024-11-06 11:07:24 |
合計ジャッジ時間 | 9,871 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 TLE * 1 -- * 1 |
ソースコード
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()); } }