結果

問題 No.2518 Adjacent Larger
ユーザー june19312june19312
提出日時 2023-10-27 22:08:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 212 ms / 2,000 ms
コード長 745 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 81,888 KB
実行使用メモリ 116,020 KB
最終ジャッジ日時 2023-10-27 22:08:43
合計ジャッジ時間 4,416 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,556 KB
testcase_01 AC 212 ms
77,896 KB
testcase_02 AC 196 ms
77,120 KB
testcase_03 AC 194 ms
77,120 KB
testcase_04 AC 204 ms
77,740 KB
testcase_05 AC 205 ms
77,924 KB
testcase_06 AC 97 ms
76,340 KB
testcase_07 AC 112 ms
76,344 KB
testcase_08 AC 102 ms
76,644 KB
testcase_09 AC 104 ms
76,728 KB
testcase_10 AC 103 ms
76,612 KB
testcase_11 AC 61 ms
75,560 KB
testcase_12 AC 62 ms
75,532 KB
testcase_13 AC 62 ms
75,484 KB
testcase_14 AC 60 ms
75,464 KB
testcase_15 AC 60 ms
75,452 KB
testcase_16 AC 104 ms
113,100 KB
testcase_17 AC 87 ms
100,276 KB
testcase_18 AC 85 ms
100,288 KB
testcase_19 AC 77 ms
96,436 KB
testcase_20 AC 93 ms
104,172 KB
testcase_21 AC 99 ms
113,116 KB
testcase_22 AC 99 ms
113,116 KB
testcase_23 AC 106 ms
113,116 KB
testcase_24 AC 93 ms
109,312 KB
testcase_25 AC 92 ms
109,624 KB
testcase_26 AC 92 ms
109,624 KB
testcase_27 AC 101 ms
116,020 KB
testcase_28 AC 109 ms
115,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())

for _ in range(T):
    N = int(input())
    A = list(map(str,input().split()))
    C = "".join(A)
    BB = []
    for ii,vv in enumerate(C):
        if vv != "1":
            BB.append(vv)
    B = "".join(BB)

    if "22" in B or "00" in B:
        print("No")
        continue
    if B.find("0") == -1 or B.find("2") == -1:
        print("No")
        continue
    if B.count("2") != B.count("0"):
        print("No")
        continue
    if B[0] == "0" and B[-1] == "0":
        print("No")
        continue
    if B[0] == "2" and B[-1] == "2":
        print("No")
        continue

    cnt = 0
    for ii,vv in enumerate(A):
        cnt += int(vv)
    if cnt != N:
        print("No")
        continue
    
    print("Yes")
0