結果
| 問題 |
No.992 最長増加部分列の数え上げ
|
| コンテスト | |
| ユーザー |
%20
|
| 提出日時 | 2020-02-05 23:11:26 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 712 bytes |
| コンパイル時間 | 2,134 ms |
| コンパイル使用メモリ | 202,668 KB |
| 最終ジャッジ日時 | 2025-01-08 22:25:19 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 TLE * 15 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
using ll=long long;
const int inf=2e9;
const int MD=1e9+7;
int main(){cin.tie(0);ios::sync_with_stdio(false);
int N;cin>>N;
vector<int>dp1={-inf};
vector<vector<int>>dp2={{inf,-inf}};
vector<vector<int>>dp3={{0,1}};
for(int _=0;_<N;++_){
int A;cin>>A;
int x=lower_bound(all(dp1),A)-dp1.begin();
if(x==dp1.size()){
dp1.push_back(A);
dp2.push_back({inf});
dp3.push_back({0});
}else{
dp1[x]=A;
}
dp2[x].push_back(A);
ll t=0;
for(int y=dp2[x-1].size()-1;dp2[x-1][y]<A;--y){
t+=dp3[x-1][y];
}
dp3[x].push_back(t%MD);
}
ll z=0;
for(int a:dp3.back()){
z+=a;
}
cout<<z%MD<<"\n";
return 0;
}
%20