結果
| 問題 |
No.209 Longest Mountain Subsequence
|
| コンテスト | |
| ユーザー |
IL_msta
|
| 提出日時 | 2015-08-15 07:18:26 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,474 bytes |
| コンパイル時間 | 641 ms |
| コンパイル使用メモリ | 85,300 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-18 09:34:54 |
| 合計ジャッジ時間 | 1,219 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 5 |
ソースコード
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <string>
//#include <array>
#include <list>
#include <queue>
#include <vector>
#include <complex>
#include <set>
#include <map>
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define PII pair<int,int>
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////
#define MAX_P 101
const int INF = (int)1e7;
int dd[MAX_P+1];
void getLIS_M(int* a,int n,int* dp){
fill(dp, dp + MAX_P + 1, INF);
fill(dd, dd + MAX_P + 1, 0);
for(int i= 0; i< n; ++i){
dp[i] = 1;
for(int j = 0; j < i; ++j){
if( a[j] < a[i] && a[i]-a[j] > dd[j] ){
if( dp[i] < dp[j] + 1){
dp[i] = dp[j] + 1;
dd[i] = a[i] - a[j];
}
}
}
}
return ;
}
int f(int* a,int* ra,int N){
int dp[MAX_P+1],rdp[MAX_P+1];
int ans = 0;
getLIS_M( a,N, dp);
getLIS_M(ra,N,rdp);
for(int i=0;i<N; ++i){
ans = max( ans,dp[i] + rdp[N-1-i] );
}
return ans - 1;
}
int main(void){
std::cin.tie(0);
std::ios::sync_with_stdio(false);
std::cout << std::fixed;//
//cout << setprecision(16);//
int T;
cin>>T;
int N;
int a[100],ra[100];
int ans[100];
fill(ans, ans + 100, 0);
rep(i,T){
cin>>N;
ans[i] = 0;
rep(j,N){
cin>>a[j];
ra[N-j-1] = a[j];
}
ans[i] = f(a,ra,N);
}
rep(i,T){
P(ans[i]);
}
return 0;
}
IL_msta