結果

問題 No.2218 Multiple LIS
ユーザー tentententen
提出日時 2024-04-03 09:51:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 486 ms / 3,000 ms
コード長 1,615 bytes
コンパイル時間 3,043 ms
コンパイル使用メモリ 79,088 KB
実行使用メモリ 61,468 KB
最終ジャッジ日時 2024-04-03 09:51:49
合計ジャッジ時間 12,662 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
55,016 KB
testcase_01 AC 67 ms
54,884 KB
testcase_02 AC 76 ms
54,752 KB
testcase_03 AC 69 ms
54,964 KB
testcase_04 AC 68 ms
54,908 KB
testcase_05 AC 68 ms
55,000 KB
testcase_06 AC 71 ms
54,884 KB
testcase_07 AC 74 ms
54,888 KB
testcase_08 AC 68 ms
54,832 KB
testcase_09 AC 67 ms
54,768 KB
testcase_10 AC 69 ms
54,880 KB
testcase_11 AC 67 ms
54,780 KB
testcase_12 AC 71 ms
54,876 KB
testcase_13 AC 76 ms
55,012 KB
testcase_14 AC 75 ms
54,896 KB
testcase_15 AC 73 ms
54,884 KB
testcase_16 AC 78 ms
54,876 KB
testcase_17 AC 75 ms
54,780 KB
testcase_18 AC 79 ms
54,876 KB
testcase_19 AC 69 ms
54,756 KB
testcase_20 AC 74 ms
55,016 KB
testcase_21 AC 127 ms
57,364 KB
testcase_22 AC 245 ms
60,548 KB
testcase_23 AC 302 ms
61,368 KB
testcase_24 AC 185 ms
57,272 KB
testcase_25 AC 320 ms
61,368 KB
testcase_26 AC 444 ms
61,436 KB
testcase_27 AC 426 ms
61,360 KB
testcase_28 AC 415 ms
61,380 KB
testcase_29 AC 420 ms
61,468 KB
testcase_30 AC 470 ms
61,420 KB
testcase_31 AC 281 ms
61,076 KB
testcase_32 AC 280 ms
61,032 KB
testcase_33 AC 274 ms
61,052 KB
testcase_34 AC 306 ms
61,400 KB
testcase_35 AC 281 ms
61,296 KB
testcase_36 AC 211 ms
60,332 KB
testcase_37 AC 486 ms
60,492 KB
testcase_38 AC 68 ms
52,812 KB
testcase_39 AC 78 ms
54,884 KB
testcase_40 AC 389 ms
61,360 KB
testcase_41 AC 399 ms
61,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int[] levels = new int[100001];
        while (n-- > 0) {
            int x = sc.nextInt();
            int current = 0;
            for (int i = 1; i <= Math.sqrt(x); i++) {
                if (x % i == 0) {
                    current = Math.max(current, levels[i]);
                    current = Math.max(current, levels[x / i]);
                }
            }
            levels[x] = current + 1;
        }
        long ans = Arrays.stream(levels).max().orElse(0);
        System.out.println(ans);
    }
}
class Scanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
        } catch (Exception e) {
            
        }
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    
    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
    
    public String next() {
        try {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return st.nextToken();
        }
    }
    
}
0