結果
| 問題 |
No.1827 最長部分スーパーリッチ門松列列
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2022-01-30 00:01:50 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 1,461 ms / 2,000 ms |
| コード長 | 653 bytes |
| コンパイル時間 | 217 ms |
| コンパイル使用メモリ | 12,032 KB |
| 実行使用メモリ | 61,052 KB |
| 最終ジャッジ日時 | 2025-01-03 00:05:54 |
| 合計ジャッジ時間 | 27,048 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 24 |
ソースコード
import sys
input = sys.stdin.readline
from operator import itemgetter
T=int(input())
for tests in range(T):
N=int(input())
P=list(map(int,input().split()))
P_INV=[-1]*N
for i in range(N):
P_INV[P[i]-1]=i
ANS=1
A=[1]*N
LANS=1
for i in range(N):
x=P_INV[i]
now=0
if x>0 and A[x-1]!=A[x]:
now+=1
if x<N-1 and A[x+1]!=A[x]:
now+=1
A[x]=0
now2=0
if x>0 and A[x-1]!=A[x]:
now2+=1
if x<N-1 and A[x+1]!=A[x]:
now2+=1
ANS+=now2-now
LANS=max(LANS,ANS)
print(LANS)
titia