結果

問題 No.1827 最長部分スーパーリッチ門松列列
ユーザー kozykozy
提出日時 2022-01-28 23:09:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 490 ms / 2,000 ms
コード長 636 bytes
コンパイル時間 2,219 ms
コンパイル使用メモリ 86,376 KB
実行使用メモリ 253,252 KB
最終ジャッジ日時 2023-08-28 21:46:49
合計ジャッジ時間 10,074 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,132 KB
testcase_01 AC 72 ms
71,024 KB
testcase_02 AC 74 ms
71,044 KB
testcase_03 AC 177 ms
78,676 KB
testcase_04 AC 156 ms
77,404 KB
testcase_05 AC 153 ms
77,400 KB
testcase_06 AC 154 ms
77,152 KB
testcase_07 AC 290 ms
252,696 KB
testcase_08 AC 277 ms
252,736 KB
testcase_09 AC 286 ms
252,756 KB
testcase_10 AC 277 ms
253,244 KB
testcase_11 AC 283 ms
253,052 KB
testcase_12 AC 277 ms
252,980 KB
testcase_13 AC 278 ms
252,932 KB
testcase_14 AC 278 ms
252,928 KB
testcase_15 AC 279 ms
252,700 KB
testcase_16 AC 273 ms
252,636 KB
testcase_17 AC 480 ms
253,048 KB
testcase_18 AC 490 ms
252,844 KB
testcase_19 AC 307 ms
252,996 KB
testcase_20 AC 313 ms
253,092 KB
testcase_21 AC 309 ms
253,252 KB
testcase_22 AC 304 ms
252,760 KB
testcase_23 AC 303 ms
252,952 KB
testcase_24 AC 303 ms
252,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
for i in range(N):
  s=int(input())
  A=list(map(int,input().split()))
  A=[0]+A+[0]
  c=dict()
  for j in range(len(A)):
    c[A[j]]=j
  if c[s]==1 or c[s]==s:
    this=2
    ans=2
  else:
    this=3
    ans=3
  for j in range(s-1,0,-1):
    if (A[c[j]]>A[c[j]-1] and A[c[j]]>A[c[j]+1]):
      if c[j]==1 or c[j]==s:
        this+=1
      else:
        this+=2
    if (A[c[j]]<A[c[j]-1] and A[c[j]]<A[c[j]+1]):
      this-=2
    if A[c[j]-1]==0:
      if A[c[j]+1]>A[c[j]]:
        this-=1
    if A[c[j]+1]==0:
      if A[c[j]-1]>A[c[j]]:
        this-=1
    
    #print(this,"a")
    
    ans=max(ans,this)
  print(ans)
0