結果

問題 No.905 Sorted?
ユーザー ThetaTheta
提出日時 2022-10-20 19:12:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 651 ms / 2,000 ms
コード長 868 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,932 KB
実行使用メモリ 21,580 KB
最終ジャッジ日時 2023-09-12 23:22:34
合計ジャッジ時間 9,254 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,268 KB
testcase_01 AC 15 ms
8,212 KB
testcase_02 AC 17 ms
8,104 KB
testcase_03 AC 16 ms
8,208 KB
testcase_04 AC 16 ms
8,100 KB
testcase_05 AC 19 ms
8,648 KB
testcase_06 AC 17 ms
8,444 KB
testcase_07 AC 25 ms
9,168 KB
testcase_08 AC 556 ms
14,584 KB
testcase_09 AC 358 ms
14,520 KB
testcase_10 AC 487 ms
19,308 KB
testcase_11 AC 541 ms
17,264 KB
testcase_12 AC 633 ms
16,428 KB
testcase_13 AC 537 ms
21,580 KB
testcase_14 AC 557 ms
21,560 KB
testcase_15 AC 636 ms
17,364 KB
testcase_16 AC 651 ms
21,412 KB
testcase_17 AC 640 ms
19,576 KB
testcase_18 AC 479 ms
19,480 KB
testcase_19 AC 15 ms
8,204 KB
testcase_20 AC 15 ms
8,176 KB
testcase_21 AC 14 ms
8,136 KB
testcase_22 AC 14 ms
8,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import pairwise


def main():
    N = int(input())
    A = list(map(int, input().split()))

    leq_table = [0]
    geq_table = [0]

    for num1, num2 in pairwise(A):
        if num1 < num2:
            leq_table.append(leq_table[-1]+1)
            geq_table.append(geq_table[-1])
        elif num1 > num2:
            leq_table.append(leq_table[-1])
            geq_table.append(geq_table[-1]+1)
        else:
            leq_table.append(leq_table[-1]+1)
            geq_table.append(geq_table[-1]+1)

    for _ in range(int(input())):
        l, r = map(int, input().split())
        if leq_table[r] - leq_table[l] == r - l:
            print("1 ", end="")
        else:
            print("0 ", end="")

        if geq_table[r] - geq_table[l] == r - l:
            print(1)
        else:
            print(0)


if __name__ == "__main__":
    main()
0