結果

問題 No.1827 最長部分スーパーリッチ門松列列
ユーザー kozykozy
提出日時 2022-01-28 23:09:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,336 ms / 2,000 ms
コード長 636 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 10,880 KB
実行使用メモリ 75,940 KB
最終ジャッジ日時 2023-08-28 21:46:23
合計ジャッジ時間 21,546 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,372 KB
testcase_01 AC 16 ms
8,236 KB
testcase_02 AC 16 ms
8,252 KB
testcase_03 AC 119 ms
8,320 KB
testcase_04 AC 379 ms
8,688 KB
testcase_05 AC 405 ms
8,692 KB
testcase_06 AC 378 ms
8,572 KB
testcase_07 AC 946 ms
75,896 KB
testcase_08 AC 957 ms
75,804 KB
testcase_09 AC 954 ms
75,868 KB
testcase_10 AC 976 ms
75,756 KB
testcase_11 AC 945 ms
75,940 KB
testcase_12 AC 945 ms
75,744 KB
testcase_13 AC 957 ms
75,764 KB
testcase_14 AC 954 ms
75,772 KB
testcase_15 AC 946 ms
75,760 KB
testcase_16 AC 953 ms
75,928 KB
testcase_17 AC 1,336 ms
75,924 KB
testcase_18 AC 1,258 ms
75,756 KB
testcase_19 AC 1,003 ms
75,856 KB
testcase_20 AC 1,009 ms
75,804 KB
testcase_21 AC 1,000 ms
75,916 KB
testcase_22 AC 1,043 ms
75,896 KB
testcase_23 AC 1,024 ms
75,864 KB
testcase_24 AC 1,036 ms
75,808 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