結果
問題 |
No.390 最長の数列
|
ユーザー |
![]() |
提出日時 | 2019-05-17 18:33:46 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 739 bytes |
コンパイル時間 | 2,277 ms |
コンパイル使用メモリ | 75,508 KB |
実行使用メモリ | 75,928 KB |
最終ジャッジ日時 | 2024-09-17 05:59:42 |
合計ジャッジ時間 | 10,343 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 1 TLE * 1 -- * 13 |
ソースコード
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner stdin = new Scanner(System.in); int n = stdin.nextInt(); int[] x = new int[n]; for (int i = 0; i < n; i++) { x[i] = stdin.nextInt(); } Arrays.sort(x); int[] dp = new int[n]; Arrays.fill(dp, 1); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (x[j] % x[i] == 0) { dp[j] = Math.max(dp[i] + 1, dp[j]); } } } int ans = Arrays.stream(dp).max().getAsInt(); System.out.println(ans); } }