結果
問題 | No.209 Longest Mountain Subsequence |
ユーザー | 37zigen |
提出日時 | 2018-04-04 02:34:24 |
言語 | Fortran (gFortran 13.2.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,085 bytes |
コンパイル時間 | 546 ms |
コンパイル使用メモリ | 27,500 KB |
実行使用メモリ | 11,132 KB |
最終ジャッジ日時 | 2023-09-08 15:36:27 |
合計ジャッジ時間 | 7,324 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | -- | - |
testcase_02 | -- | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
ソースコード
module m implicit none integer::n integer::a(100),f(100,100) contains recursive integer function g(s,t)result(res) implicit none integer::s,t integer::i,j,k,dy if(f(s,t)>=0)then res=f(s,t) return end if res=2 dy=a(t)-a(s) do i=t+1,n if(dy>0.and.a(t)-a(s)<a(i)-a(t))then res=max(res,1+g(t,i)) else if(dy>0.and.a(i)<a(t))then res=max(res,1+g(t,i)) else if(dy<0.and.a(s)-a(t)>a(t)-a(i).and.a(t)>a(i))then res=max(res,1+g(t,i)) end if end do end function end module program main use m implicit none integer::t,i,j,k,x,y,r,ans read*,t do i=1,t read*,n do j=1,n do k=j+1,n f(j,k)=-1 end do end do read*,(a(j),j=1,n) ans=1 do j=1,n do k=j+1,n ans=max(ans,g(j,k)) end do end do print*,ans end do end program