結果

問題 No.992 最長増加部分列の数え上げ
ユーザー htensaihtensai
提出日時 2020-05-01 10:40:30
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,326 bytes
コンパイル時間 2,461 ms
コンパイル使用メモリ 75,680 KB
実行使用メモリ 83,580 KB
最終ジャッジ日時 2023-08-25 01:39:57
合計ジャッジ時間 30,301 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
60,176 KB
testcase_01 AC 107 ms
55,744 KB
testcase_02 AC 107 ms
56,120 KB
testcase_03 AC 107 ms
55,912 KB
testcase_04 AC 728 ms
70,328 KB
testcase_05 AC 606 ms
69,368 KB
testcase_06 AC 762 ms
71,972 KB
testcase_07 AC 651 ms
69,960 KB
testcase_08 AC 490 ms
63,376 KB
testcase_09 AC 663 ms
69,984 KB
testcase_10 AC 758 ms
72,428 KB
testcase_11 AC 904 ms
72,308 KB
testcase_12 AC 429 ms
61,208 KB
testcase_13 AC 662 ms
69,632 KB
testcase_14 AC 654 ms
69,652 KB
testcase_15 AC 415 ms
61,180 KB
testcase_16 AC 1,076 ms
81,264 KB
testcase_17 AC 523 ms
63,644 KB
testcase_18 AC 657 ms
69,380 KB
testcase_19 AC 877 ms
70,492 KB
testcase_20 AC 1,114 ms
82,124 KB
testcase_21 AC 1,199 ms
81,716 KB
testcase_22 AC 1,114 ms
82,428 KB
testcase_23 AC 1,101 ms
81,456 KB
testcase_24 AC 1,160 ms
82,360 KB
testcase_25 AC 1,182 ms
81,364 KB
testcase_26 AC 1,246 ms
83,580 KB
testcase_27 AC 1,183 ms
81,932 KB
testcase_28 AC 1,186 ms
81,540 KB
testcase_29 AC 1,213 ms
81,668 KB
testcase_30 TLE -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<TreeMap<Integer, Integer>> dp = new ArrayList<>();
		dp.add(new TreeMap<>());
		dp.get(0).put(Integer.MIN_VALUE, 1);
		for (int i = 0; i < n; i++) {
		    int x = sc.nextInt();
		    int left = 0;
		    int right = dp.size();
		    while (right - left > 1) {
		        int m = (left + right) / 2;
		        boolean flag = true;
		        if (dp.get(m).firstKey() < x) {
		            left = m;
		        } else {
		            right = m;
		        }
		    }
		    int count = 0;
		    for (Map.Entry<Integer, Integer> entry : dp.get(left).entrySet()) {
		        if (entry.getKey() < x) {
		            count += entry.getValue();
		            count %= MOD;
		        } else {
		            break;
		        }
		    }
		    if (dp.size() <= left + 1) {
		        dp.add(new TreeMap<>());
		    }
		    if (dp.get(left + 1).containsKey(x)) {
		        dp.get(left + 1).put(x, (dp.get(left + 1).get(x) + count) % MOD);
		    } else {
		        dp.get(left + 1).put(x, count);
		    }
		}
		int total = 0;
		for (int x : dp.get(dp.size() - 1).values()) {
		    total += x;
		    total %= MOD;
		}
		System.out.println(total);
	}
}
0