結果

問題 No.2218 Multiple LIS
ユーザー tentententen
提出日時 2023-03-30 14:49:46
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 2,157 bytes
コンパイル時間 4,441 ms
コンパイル使用メモリ 84,808 KB
実行使用メモリ 64,960 KB
最終ジャッジ日時 2023-10-22 01:02:46
合計ジャッジ時間 12,598 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
53,632 KB
testcase_01 AC 50 ms
53,624 KB
testcase_02 AC 49 ms
52,528 KB
testcase_03 AC 50 ms
53,632 KB
testcase_04 AC 56 ms
52,584 KB
testcase_05 AC 51 ms
53,632 KB
testcase_06 AC 50 ms
53,632 KB
testcase_07 AC 50 ms
53,624 KB
testcase_08 AC 47 ms
53,632 KB
testcase_09 AC 49 ms
53,636 KB
testcase_10 AC 49 ms
53,636 KB
testcase_11 AC 49 ms
53,632 KB
testcase_12 AC 55 ms
53,652 KB
testcase_13 AC 90 ms
55,548 KB
testcase_14 AC 84 ms
55,024 KB
testcase_15 AC 81 ms
54,944 KB
testcase_16 AC 52 ms
53,636 KB
testcase_17 AC 95 ms
55,172 KB
testcase_18 AC 50 ms
53,636 KB
testcase_19 AC 55 ms
52,884 KB
testcase_20 AC 84 ms
54,812 KB
testcase_21 AC 344 ms
57,296 KB
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        ArrayList<HashSet<Integer>> dp = new ArrayList<>();
        dp.add(new HashSet<>());
        dp.get(0).add(1);
        while (n-- > 0) {
            int x = sc.nextInt();
            boolean enable = false;
            for (int i = dp.size() - 1; i >= 0 && !enable; i--) {
                for (int y : dp.get(i)) {
                    if (x % y == 0) {
                        enable = true;
                        if (i == dp.size() - 1) {
                            dp.add(new HashSet<>());
                        }
                        dp.get(i + 1).add(x);
                        break;
                    }
                }
            }
        }
        System.out.println(dp.size() - 1);
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0