結果
問題 | No.992 最長増加部分列の数え上げ |
ユーザー |
![]() |
提出日時 | 2020-08-24 19:05:08 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,534 bytes |
コンパイル時間 | 3,338 ms |
コンパイル使用メモリ | 79,700 KB |
実行使用メモリ | 85,984 KB |
最終ジャッジ日時 | 2024-11-06 10:36:11 |
合計ジャッジ時間 | 37,928 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 TLE * 1 -- * 14 |
ソースコード
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>> list = new ArrayList<>();list.add(new TreeMap<>());list.get(0).put(Integer.MIN_VALUE, 1);for (int i = 0; i < n; i++) {int x = sc.nextInt();int left = 0;int right = list.size();while (right - left > 1) {int m = (left + right) / 2;if (list.get(m).firstKey() >= x) {right = m;} else {left = m;}}if (left == list.size() - 1) {list.add(new TreeMap<>());}int count = 0;for (Map.Entry<Integer, Integer> entry : list.get(left).entrySet()) {if (entry.getKey() >= x) {break;}count += entry.getValue();count %= MOD;}if (list.get(left + 1).containsKey(x)) {list.get(left + 1).put(x, (list.get(left + 1).get(x) + count) % MOD);} else {list.get(left + 1).put(x, count);}}int sum = 0;for (int x : list.get(list.size() - 1).values()) {sum += x;sum %= MOD;}System.out.println(sum);}}