結果

問題 No.905 Sorted?
ユーザー wattaiheiwattaihei
提出日時 2019-10-11 22:19:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 495 ms / 2,000 ms
コード長 1,013 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 38,908 KB
最終ジャッジ日時 2024-05-04 02:02:09
合計ジャッジ時間 6,422 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,880 KB
testcase_01 AC 29 ms
10,880 KB
testcase_02 AC 29 ms
10,752 KB
testcase_03 AC 30 ms
10,752 KB
testcase_04 AC 29 ms
10,752 KB
testcase_05 AC 33 ms
11,136 KB
testcase_06 AC 30 ms
10,880 KB
testcase_07 AC 48 ms
11,776 KB
testcase_08 AC 374 ms
31,356 KB
testcase_09 AC 265 ms
25,248 KB
testcase_10 AC 419 ms
32,320 KB
testcase_11 AC 421 ms
32,160 KB
testcase_12 AC 462 ms
34,692 KB
testcase_13 AC 449 ms
34,960 KB
testcase_14 AC 458 ms
34,696 KB
testcase_15 AC 492 ms
34,332 KB
testcase_16 AC 491 ms
36,000 KB
testcase_17 AC 495 ms
38,908 KB
testcase_18 AC 399 ms
33,356 KB
testcase_19 AC 28 ms
10,752 KB
testcase_20 AC 27 ms
10,752 KB
testcase_21 AC 26 ms
10,880 KB
testcase_22 AC 27 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]

increase = [0 for _ in range(N)]

l = 0
r = 0
while l < N-1:
    if r < N-1:
        if A[r] <= A[r+1]:
            r += 1
        elif l == r:
            increase[l] = r
            r += 1
            l += 1
        else:
            increase[l] = r
            l += 1
    else:
        increase[l] = r
        l += 1

decrease = [0 for _ in range(N)]

l = 0
r = 0
while l < N-1:
    if r < N-1:
        if A[r] >= A[r+1]:
            r += 1
        elif l == r:
            decrease[l] = r
            r += 1
            l += 1
        else:
            decrease[l] = r
            l += 1
    else:
        decrease[l] = r
        l += 1

increase[N-1] = N-1
decrease[N-1] = N-1

for l, r in Query:
    if r <= increase[l]:
        a = 1
    else:
        a = 0
    if r <= decrease[l]:
        b = 1
    else:
        b = 0
    print(a, b)
0