結果

問題 No.905 Sorted?
ユーザー roarisroaris
提出日時 2019-11-21 18:27:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 342 ms / 2,000 ms
コード長 705 bytes
コンパイル時間 323 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 114,048 KB
最終ジャッジ日時 2024-04-19 03:39:15
合計ジャッジ時間 5,971 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
51,712 KB
testcase_01 AC 46 ms
52,224 KB
testcase_02 AC 44 ms
51,840 KB
testcase_03 AC 42 ms
52,096 KB
testcase_04 AC 41 ms
51,840 KB
testcase_05 AC 68 ms
65,792 KB
testcase_06 AC 56 ms
62,592 KB
testcase_07 AC 84 ms
74,496 KB
testcase_08 AC 311 ms
90,496 KB
testcase_09 AC 238 ms
89,984 KB
testcase_10 AC 300 ms
103,680 KB
testcase_11 AC 313 ms
104,448 KB
testcase_12 AC 342 ms
100,480 KB
testcase_13 AC 311 ms
102,420 KB
testcase_14 AC 320 ms
102,552 KB
testcase_15 AC 341 ms
113,536 KB
testcase_16 AC 339 ms
113,920 KB
testcase_17 AC 341 ms
113,920 KB
testcase_18 AC 291 ms
114,048 KB
testcase_19 AC 39 ms
51,840 KB
testcase_20 AC 38 ms
51,840 KB
testcase_21 AC 39 ms
51,840 KB
testcase_22 AC 39 ms
51,840 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