結果
| 問題 |
No.992 最長増加部分列の数え上げ
|
| コンテスト | |
| ユーザー |
otamay6
|
| 提出日時 | 2020-02-14 23:08:04 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,017 bytes |
| コンパイル時間 | 1,683 ms |
| コンパイル使用メモリ | 170,424 KB |
| 実行使用メモリ | 10,496 KB |
| 最終ジャッジ日時 | 2024-10-06 13:12:08 |
| 合計ジャッジ時間 | 5,933 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 1 TLE * 1 -- * 40 |
ソースコード
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;
int main(){
constexpr ll mod=1e9+7;
int N;cin>>N;
vector<int> a(N+1,-1e9-1);
REP(i, N) cin >> a[i+1];
vector<pair<ll,int>> dp(N+1);
dp[0]=make_pair(1,1);
REP(i,N) REP(j,i+1){
if(a[j]<a[i+1]){
if(dp[j].second+1>dp[i+1].second){
dp[i+1]=dp[j];
dp[i+1].second++;
}
else if(dp[j].second+1==dp[i+1].second){
dp[i+1].first+=dp[j].first;
dp[i+1].first%=mod;
}
}
}
pair<ll,int> ans=make_pair(0,0);
REP(i,N+1){
if(dp[i].second>ans.second){
ans=dp[i];
}
else if(dp[i].second==ans.second){
ans.first+=dp[i].first;
}
}
cout<<ans.first<<endl;
}
otamay6