結果

問題 No.1438 Broken Drawers
ユーザー 炭酸水炭酸水
提出日時 2022-05-14 05:38:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,102 bytes
コンパイル時間 463 ms
コンパイル使用メモリ 10,808 KB
実行使用メモリ 30,852 KB
最終ジャッジ日時 2023-09-29 17:56:22
合計ジャッジ時間 7,546 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,368 KB
testcase_01 AC 15 ms
8,252 KB
testcase_02 AC 14 ms
8,216 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 15 ms
8,180 KB
testcase_06 AC 163 ms
30,040 KB
testcase_07 AC 192 ms
29,952 KB
testcase_08 AC 15 ms
8,248 KB
testcase_09 AC 15 ms
8,248 KB
testcase_10 AC 15 ms
8,404 KB
testcase_11 AC 26 ms
9,356 KB
testcase_12 AC 99 ms
16,972 KB
testcase_13 AC 149 ms
22,260 KB
testcase_14 AC 71 ms
14,200 KB
testcase_15 AC 224 ms
29,408 KB
testcase_16 AC 215 ms
27,760 KB
testcase_17 AC 233 ms
30,064 KB
testcase_18 AC 233 ms
30,292 KB
testcase_19 AC 235 ms
30,424 KB
testcase_20 AC 240 ms
30,728 KB
testcase_21 AC 231 ms
30,228 KB
testcase_22 AC 239 ms
30,852 KB
testcase_23 AC 240 ms
30,116 KB
testcase_24 AC 238 ms
30,096 KB
testcase_25 AC 238 ms
30,100 KB
testcase_26 AC 238 ms
30,080 KB
testcase_27 AC 239 ms
30,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))

z = []

if a[0] < a[1]:
    z.append(True)
elif a[0] > a[1]:
    if a[1] < a[2]:
        z.append(False)
    elif a[1] > a[2]:
        z.append(True)

for i in range(1, n - 1):
    if a[i - 1] < a[i] < a[i + 1]:
        z.append(True)
    
    elif a[i - 1] > a[i] > a[i + 1]:
        if z[i - 1]:
            z.append(False)
        else:
            z.append(True)
    
    elif a[i - 1] > a[i] < a[i + 1]:
        if z[i - 1]:
            z.append(False)
        else:
            z.append(True)
    
    elif a[i - 1] < a[i] > a[i + 1]:
        if z[i - 1]:
            z.append(True)
        else:
            if i < n - 2:
                if a[i + 1] < a[i + 2]:
                    z.append(False)
                elif a[i + 1] > a[i + 2]:
                    z.append(True)
            elif i == n - 2:
                z.append(True)

if a[-2] < a[-1]:
    z.append(True)
elif a[-2] > a[-1]:
    if z[-1]:
        z.append(False)
    else:
        z.append(True)

ans = 0        
for i in range(n):
    if z[i]:
        ans += 1

print(ans)
0