結果
| 問題 | No.2518 Adjacent Larger |
| コンテスト | |
| ユーザー |
H20
|
| 提出日時 | 2023-10-27 22:54:11 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 237 ms / 2,000 ms |
| コード長 | 510 bytes |
| 記録 | |
| コンパイル時間 | 679 ms |
| コンパイル使用メモリ | 82,388 KB |
| 実行使用メモリ | 104,400 KB |
| 最終ジャッジ日時 | 2024-09-25 14:56:57 |
| 合計ジャッジ時間 | 4,692 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 28 |
ソースコード
import collections
T = int(input())
for _ in range(T):
N = int(input())
A = list(map(int, input().split()))
C = collections.Counter(A)
ans = C[0]==C[2] and C[1]<N
temp = 0
mitemp = 0
matemp = 0
for i in range(N):
if A[i]==A[i-1] and A[i]!=1:
ans = False
temp+=A[i]-1
mitemp = min(temp,mitemp)
matemp = max(temp,matemp)
if matemp-mitemp>1:
ans = False
if ans:
print('Yes')
else:
print('No')
H20