結果

問題 No.905 Sorted?
ユーザー crow_vanishcrow_vanish
提出日時 2019-10-11 23:01:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 342 ms / 2,000 ms
コード長 646 bytes
コンパイル時間 934 ms
コンパイル使用メモリ 87,208 KB
実行使用メモリ 93,532 KB
最終ジャッジ日時 2023-08-16 19:24:44
合計ジャッジ時間 5,895 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,208 KB
testcase_01 AC 70 ms
75,328 KB
testcase_02 AC 67 ms
71,380 KB
testcase_03 AC 65 ms
71,364 KB
testcase_04 AC 64 ms
71,556 KB
testcase_05 AC 86 ms
76,788 KB
testcase_06 AC 79 ms
76,756 KB
testcase_07 AC 94 ms
77,804 KB
testcase_08 AC 328 ms
87,836 KB
testcase_09 AC 264 ms
84,900 KB
testcase_10 AC 303 ms
92,340 KB
testcase_11 AC 308 ms
88,200 KB
testcase_12 AC 319 ms
89,660 KB
testcase_13 AC 306 ms
93,532 KB
testcase_14 AC 342 ms
93,464 KB
testcase_15 AC 276 ms
90,840 KB
testcase_16 AC 232 ms
91,504 KB
testcase_17 AC 287 ms
91,348 KB
testcase_18 AC 273 ms
91,348 KB
testcase_19 AC 64 ms
71,548 KB
testcase_20 AC 65 ms
71,276 KB
testcase_21 AC 64 ms
71,532 KB
testcase_22 AC 65 ms
71,084 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