結果

問題 No.905 Sorted?
ユーザー daku9640daku9640
提出日時 2019-10-11 21:56:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 730 ms / 2,000 ms
コード長 642 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 23,004 KB
最終ジャッジ日時 2024-05-04 01:33:05
合計ジャッジ時間 8,375 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,624 KB
testcase_01 AC 29 ms
10,624 KB
testcase_02 AC 27 ms
10,624 KB
testcase_03 AC 27 ms
10,624 KB
testcase_04 AC 26 ms
10,624 KB
testcase_05 AC 30 ms
11,008 KB
testcase_06 AC 30 ms
11,008 KB
testcase_07 AC 35 ms
11,776 KB
testcase_08 AC 567 ms
16,204 KB
testcase_09 AC 379 ms
16,236 KB
testcase_10 AC 506 ms
21,572 KB
testcase_11 AC 569 ms
19,036 KB
testcase_12 AC 678 ms
17,668 KB
testcase_13 AC 628 ms
22,644 KB
testcase_14 AC 704 ms
21,968 KB
testcase_15 AC 730 ms
18,620 KB
testcase_16 AC 689 ms
23,004 KB
testcase_17 AC 660 ms
20,692 KB
testcase_18 AC 500 ms
20,564 KB
testcase_19 AC 26 ms
10,624 KB
testcase_20 AC 25 ms
10,752 KB
testcase_21 AC 26 ms
10,624 KB
testcase_22 AC 25 ms
10,624 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