結果
| 問題 |
No.209 Longest Mountain Subsequence
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-04 15:02:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 780 bytes |
| コンパイル時間 | 531 ms |
| コンパイル使用メモリ | 68,480 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-14 00:15:14 |
| 合計ジャッジ時間 | 1,087 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 5 |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
8 | main()
| ^~~~
ソースコード
#include<iostream>
#include<algorithm>
#include<utility>
using namespace std;
int T,N;
int A[100];
pair<int,int>L[100],R[100];
main()
{
cin>>T;
for(;T--;)
{
cin>>N;
for(int i=0;i<N;i++)cin>>A[i];
for(int i=0;i<N;i++)
{
L[i]=make_pair(1,0);
for(int j=0;j<i;j++)
{
if(A[j]<A[i]&&-L[j].second<A[i]-A[j])
{
pair<int,int>p;
p.first=L[j].first+1;
p.second=-(A[i]-A[j]);
L[i]=max(L[i],p);
}
}
}
for(int i=N;i--;)
{
R[i]=make_pair(1,0);
for(int j=N;--j>i;)
{
if(A[j]<A[i]&&-R[j].second<A[i]-A[j])
{
pair<int,int>p;
p.first=R[j].first+1;
p.second=-(A[i]-A[j]);
R[i]=max(R[i],p);
}
}
}
int ans=0;
for(int i=0;i<N;i++)ans=max(ans,L[i].first+R[i].first-1);
cout<<ans<<endl;
}
}