結果

問題 No.2218 Multiple LIS
ユーザー tentententen
提出日時 2024-04-03 09:47:21
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,910 bytes
コンパイル時間 2,479 ms
コンパイル使用メモリ 78,896 KB
実行使用メモリ 67,540 KB
最終ジャッジ日時 2024-04-03 09:47:39
合計ジャッジ時間 14,373 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
53,988 KB
testcase_01 AC 56 ms
53,992 KB
testcase_02 AC 56 ms
53,944 KB
testcase_03 AC 56 ms
53,988 KB
testcase_04 AC 56 ms
53,964 KB
testcase_05 AC 55 ms
53,976 KB
testcase_06 AC 54 ms
54,032 KB
testcase_07 AC 55 ms
53,992 KB
testcase_08 AC 60 ms
53,976 KB
testcase_09 AC 54 ms
53,976 KB
testcase_10 AC 56 ms
54,000 KB
testcase_11 AC 56 ms
53,964 KB
testcase_12 AC 60 ms
53,988 KB
testcase_13 AC 95 ms
55,012 KB
testcase_14 AC 92 ms
54,528 KB
testcase_15 AC 80 ms
54,632 KB
testcase_16 AC 61 ms
53,992 KB
testcase_17 AC 86 ms
55,008 KB
testcase_18 AC 57 ms
53,988 KB
testcase_19 AC 60 ms
53,976 KB
testcase_20 AC 88 ms
54,780 KB
testcase_21 AC 233 ms
56,524 KB
testcase_22 TLE -
testcase_23 TLE -
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.function.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        List<List<Integer>> lengths = new ArrayList<>();
        lengths.add(new ArrayList<>());
        lengths.get(0).add(1);
        while (n-- > 0) {
            int y = sc.nextInt();
            for (int i = lengths.size() - 1; i >= 0; i--) {
                boolean enable = false;
                for (int x : lengths.get(i)) {
                    enable = (y % x == 0);
                    if (enable) {
                        break;
                    }
                }
                if (enable) {
                    if (i == lengths.size() - 1) {
                        lengths.add(new ArrayList<>());
                    }
                    lengths.get(i + 1).add(y);
                    break;
                }
            }
        }
        System.out.println(lengths.size() - 1);
    }
}
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