結果

問題 No.905 Sorted?
ユーザー crow_vanishcrow_vanish
提出日時 2019-10-11 23:01:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 350 ms / 2,000 ms
コード長 646 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 92,672 KB
最終ジャッジ日時 2024-05-04 02:53:45
合計ジャッジ時間 5,450 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
51,968 KB
testcase_01 AC 45 ms
58,624 KB
testcase_02 AC 44 ms
52,864 KB
testcase_03 AC 39 ms
52,736 KB
testcase_04 AC 39 ms
53,120 KB
testcase_05 AC 64 ms
68,864 KB
testcase_06 AC 54 ms
63,744 KB
testcase_07 AC 84 ms
76,288 KB
testcase_08 AC 350 ms
86,328 KB
testcase_09 AC 269 ms
83,344 KB
testcase_10 AC 316 ms
91,776 KB
testcase_11 AC 315 ms
86,864 KB
testcase_12 AC 348 ms
86,512 KB
testcase_13 AC 300 ms
92,516 KB
testcase_14 AC 345 ms
92,672 KB
testcase_15 AC 263 ms
89,164 KB
testcase_16 AC 231 ms
90,496 KB
testcase_17 AC 292 ms
90,388 KB
testcase_18 AC 279 ms
90,368 KB
testcase_19 AC 35 ms
53,004 KB
testcase_20 AC 35 ms
52,744 KB
testcase_21 AC 34 ms
54,004 KB
testcase_22 AC 35 ms
53,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
a=list(map(int,input().split()))
q=int(input())
lr=[]
for i in range(q):
    l,r=map(int,input().split())
    lr.append((l,r))

f=[]
g=[]
f.append(0)
g.append(0)
for i in range(n-1):
    if a[i]>a[i+1]:
        f.append(i+1)

for i in range(n-1):
    if a[i]<a[i+1]:
        g.append(i+1)

import bisect

for i in range(q):
    l,r=lr[i]
    idx_l=bisect.bisect_right(f,l)
    idx_r=bisect.bisect_right(f,r)
    if (idx_l==idx_r):
        flag1=1
    else:
        flag1=0
    idx_l=bisect.bisect_right(g,l)
    idx_r=bisect.bisect_right(g,r)
    if (idx_l==idx_r):
        flag2=1
    else:
        flag2=0
    print(flag1,flag2)
0