結果
| 問題 |
No.390 最長の数列
|
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2020-09-29 13:44:17 |
| 言語 | Java (openjdk 23) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,093 bytes |
| コンパイル時間 | 2,506 ms |
| コンパイル使用メモリ | 79,356 KB |
| 実行使用メモリ | 67,572 KB |
| 最終ジャッジ日時 | 2024-07-03 20:08:07 |
| 合計ジャッジ時間 | 10,025 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 1 TLE * 1 -- * 13 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = sc.nextInt();
}
Arrays.sort(arr);
ArrayList<ArrayList<Integer>> lists = new ArrayList<>();
for (int i = 0; i < n; i++) {
lists.add(new ArrayList<>());
}
int max = 0;
for (int i = 0; i < n; i++) {
boolean flag = true;
for (int j = max - 1; j >= 0 && flag; j--) {
for (int x : lists.get(j)) {
if (arr[i] % x == 0) {
lists.get(j + 1).add(arr[i]);
max = Math.max(max, j + 2);
flag = false;
break;
}
}
}
if (flag) {
lists.get(0).add(arr[i]);
max = Math.max(1, max);
}
}
System.out.println(max);
}
}
tenten