結果

問題 No.905 Sorted?
ユーザー wattaiheiwattaihei
提出日時 2019-10-11 22:19:45
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 483 ms / 2,000 ms
コード長 1,013 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 11,020 KB
実行使用メモリ 36,772 KB
最終ジャッジ日時 2023-08-16 18:27:12
合計ジャッジ時間 6,683 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,172 KB
testcase_01 AC 16 ms
8,376 KB
testcase_02 AC 16 ms
8,228 KB
testcase_03 AC 16 ms
8,216 KB
testcase_04 AC 17 ms
8,296 KB
testcase_05 AC 23 ms
8,696 KB
testcase_06 AC 19 ms
8,324 KB
testcase_07 AC 35 ms
9,352 KB
testcase_08 AC 345 ms
29,172 KB
testcase_09 AC 247 ms
22,568 KB
testcase_10 AC 412 ms
29,948 KB
testcase_11 AC 407 ms
29,532 KB
testcase_12 AC 442 ms
32,444 KB
testcase_13 AC 448 ms
32,572 KB
testcase_14 AC 449 ms
32,336 KB
testcase_15 AC 483 ms
31,828 KB
testcase_16 AC 468 ms
33,596 KB
testcase_17 AC 467 ms
36,772 KB
testcase_18 AC 389 ms
30,812 KB
testcase_19 AC 16 ms
8,236 KB
testcase_20 AC 16 ms
8,292 KB
testcase_21 AC 17 ms
8,252 KB
testcase_22 AC 16 ms
8,212 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