結果

問題 No.905 Sorted?
ユーザー roarisroaris
提出日時 2019-11-21 18:27:33
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 366 ms / 2,000 ms
コード長 705 bytes
コンパイル時間 461 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 115,596 KB
最終ジャッジ日時 2023-08-01 03:56:22
合計ジャッジ時間 7,787 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,388 KB
testcase_01 AC 72 ms
71,352 KB
testcase_02 AC 73 ms
71,400 KB
testcase_03 AC 71 ms
71,484 KB
testcase_04 AC 71 ms
71,468 KB
testcase_05 AC 89 ms
76,900 KB
testcase_06 AC 81 ms
76,436 KB
testcase_07 AC 103 ms
77,924 KB
testcase_08 AC 333 ms
89,168 KB
testcase_09 AC 260 ms
91,064 KB
testcase_10 AC 316 ms
103,916 KB
testcase_11 AC 331 ms
105,712 KB
testcase_12 AC 366 ms
101,744 KB
testcase_13 AC 346 ms
104,256 KB
testcase_14 AC 350 ms
104,300 KB
testcase_15 AC 360 ms
108,512 KB
testcase_16 AC 365 ms
115,596 KB
testcase_17 AC 358 ms
115,424 KB
testcase_18 AC 307 ms
111,816 KB
testcase_19 AC 68 ms
71,268 KB
testcase_20 AC 74 ms
71,320 KB
testcase_21 AC 68 ms
71,656 KB
testcase_22 AC 68 ms
71,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
incre, decre = [], []

for i in range(N-1):
    if A[i]<=A[i+1]:
        incre.append(1)
    else:
        incre.append(0)
    
    if A[i]>=A[i+1]:
        decre.append(1)
    else:
        decre.append(0)

incre_acc = [0]
decre_acc = [0]

for incre_i in incre:
    incre_acc.append(incre_acc[-1]+incre_i)

for decre_i in decre:
    decre_acc.append(decre_acc[-1]+decre_i)

Q = int(input())

for _ in range(Q):
    li, ri = map(int, input().split())
    
    if incre_acc[ri]-incre_acc[li]==ri-li:
        print(1, end=' ')
    else:
        print(0, end=' ')
    
    if decre_acc[ri]-decre_acc[li]==ri-li:
        print(1)
    else:
        print(0)
0