結果

問題 No.905 Sorted?
ユーザー daku9640daku9640
提出日時 2019-10-11 21:56:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 669 ms / 2,000 ms
コード長 642 bytes
コンパイル時間 598 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 21,660 KB
最終ジャッジ日時 2023-08-16 17:45:43
合計ジャッジ時間 8,301 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,748 KB
testcase_01 AC 16 ms
7,864 KB
testcase_02 AC 16 ms
7,840 KB
testcase_03 AC 16 ms
7,776 KB
testcase_04 AC 16 ms
7,844 KB
testcase_05 AC 20 ms
8,596 KB
testcase_06 AC 17 ms
8,444 KB
testcase_07 AC 24 ms
9,176 KB
testcase_08 AC 551 ms
14,740 KB
testcase_09 AC 368 ms
13,888 KB
testcase_10 AC 504 ms
19,324 KB
testcase_11 AC 553 ms
17,216 KB
testcase_12 AC 644 ms
16,368 KB
testcase_13 AC 567 ms
21,660 KB
testcase_14 AC 567 ms
21,540 KB
testcase_15 AC 648 ms
17,304 KB
testcase_16 AC 669 ms
20,512 KB
testcase_17 AC 652 ms
19,588 KB
testcase_18 AC 477 ms
19,428 KB
testcase_19 AC 15 ms
7,828 KB
testcase_20 AC 15 ms
7,752 KB
testcase_21 AC 15 ms
7,828 KB
testcase_22 AC 15 ms
7,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    n = int(input())
    A = list(map(int, input().split()))
    P = [0] * n
    M = [0] * n
    cnt = 0
    for i in range(1, n):
        if A[i - 1] <= A[i]:
            cnt += 1
            P[i] = cnt
        else:
            cnt = 0
    cnt = 0
    for i in range(1, n):
        if A[i - 1] >= A[i]:
            cnt += 1
            M[i] = cnt
        else:
            cnt = 0
    q = int(input())
    for _ in range(q):
        l, r = map(int, input().split())
        ans = [0, 0]
        if P[r] - P[l] == r - l:
            ans[0] = 1
        if M[r] - M[l] == r - l:
            ans[1] = 1
        print(*ans)
solve()
0