結果

問題 No.905 Sorted?
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-05-04 10:30:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 356 ms / 2,000 ms
コード長 658 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 86,960 KB
実行使用メモリ 113,476 KB
最終ジャッジ日時 2023-09-16 11:46:22
合計ジャッジ時間 6,865 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,252 KB
testcase_01 AC 72 ms
70,964 KB
testcase_02 AC 71 ms
70,848 KB
testcase_03 AC 71 ms
70,688 KB
testcase_04 AC 70 ms
70,980 KB
testcase_05 AC 155 ms
76,532 KB
testcase_06 AC 86 ms
76,352 KB
testcase_07 AC 107 ms
77,576 KB
testcase_08 AC 301 ms
102,092 KB
testcase_09 AC 250 ms
95,148 KB
testcase_10 AC 301 ms
100,816 KB
testcase_11 AC 332 ms
104,376 KB
testcase_12 AC 356 ms
108,252 KB
testcase_13 AC 334 ms
103,976 KB
testcase_14 AC 325 ms
103,768 KB
testcase_15 AC 294 ms
110,456 KB
testcase_16 AC 294 ms
113,476 KB
testcase_17 AC 292 ms
112,872 KB
testcase_18 AC 253 ms
104,188 KB
testcase_19 AC 67 ms
70,908 KB
testcase_20 AC 67 ms
70,960 KB
testcase_21 AC 66 ms
70,956 KB
testcase_22 AC 68 ms
71,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int,input().split()))
q = int(input())
LR = [list(map(int,input().split())) for i in range(q)]
ans = [[0,0] for i in range(q)]
query = [[] for i in range(n)]
for i,(l,r) in enumerate(LR):
    query[l].append((r+1,i))

now = 0
for i,a in enumerate(A):
    now = max(i+1,now)
    while now < n and A[now] >= A[now-1]:
        now += 1
    for r,ind in query[i]:
        if r <= now:
            ans[ind][0] = 1

now = 0
for i,a in enumerate(A):
    now = max(i+1,now)
    while now < n and A[now] <= A[now-1]:
        now += 1
    for r,ind in query[i]:
        if r <= now:
            ans[ind][1] = 1
for i in ans:
    print(*i)
0