結果

問題 No.390 最長の数列
ユーザー neko_the_shadowneko_the_shadow
提出日時 2019-05-17 18:33:46
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 739 bytes
コンパイル時間 2,429 ms
コンパイル使用メモリ 75,496 KB
実行使用メモリ 57,748 KB
最終ジャッジ日時 2023-10-17 07:24:55
合計ジャッジ時間 11,394 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
57,692 KB
testcase_01 AC 127 ms
57,748 KB
testcase_02 AC 125 ms
57,440 KB
testcase_03 AC 124 ms
57,636 KB
testcase_04 AC 123 ms
57,412 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
    }
}
0