結果
| 問題 |
No.209 Longest Mountain Subsequence
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-02-09 00:35:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 592 bytes |
| コンパイル時間 | 2,575 ms |
| コンパイル使用メモリ | 192,600 KB |
| 最終ジャッジ日時 | 2025-01-08 23:15:43 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 5 |
コンパイルメッセージ
main.cpp: In function ‘void solve()’:
main.cpp:8:28: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | int n,a[100]; scanf("%d",&n);
| ~~~~~^~~~~~~~~
main.cpp:9:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | rep(i,n) scanf("%d",&a[i]);
| ~~~~~^~~~~~~~~~~~
main.cpp: In function ‘int main()’:
main.cpp:29:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
29 | int q; scanf("%d",&q); rep(_,q) solve();
| ~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
void solve(){
int n,a[100]; scanf("%d",&n);
rep(i,n) scanf("%d",&a[i]);
int dp[2][100];
rep(t,2){
rep(i,n) dp[t][i]=1;
for(int i=1;i<n;i++) rep(j,i) if(a[j]<a[i]) dp[t][i]=2;
for(int i=2;i<n;i++){
rep(j,i) if(a[j]<a[i]) rep(k,j) if(a[k]<a[j] && a[j]-a[k]<a[i]-a[j]) {
dp[t][i]=max(dp[t][i],dp[t][j]+1);
}
}
reverse(a,a+n);
}
int ans=0;
rep(i,n) ans=max(ans,dp[0][i]+dp[1][n-i-1]-1);
printf("%d\n",ans);
}
int main(){
int q; scanf("%d",&q); rep(_,q) solve();
return 0;
}