結果

問題 No.905 Sorted?
ユーザー lloyzlloyz
提出日時 2022-05-02 00:50:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 382 ms / 2,000 ms
コード長 619 bytes
コンパイル時間 876 ms
コンパイル使用メモリ 86,956 KB
実行使用メモリ 94,500 KB
最終ジャッジ日時 2023-09-13 18:27:58
合計ジャッジ時間 8,764 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,244 KB
testcase_01 AC 76 ms
71,372 KB
testcase_02 AC 76 ms
71,296 KB
testcase_03 AC 77 ms
71,204 KB
testcase_04 AC 76 ms
71,452 KB
testcase_05 AC 100 ms
76,528 KB
testcase_06 AC 86 ms
76,464 KB
testcase_07 AC 105 ms
76,916 KB
testcase_08 AC 359 ms
84,900 KB
testcase_09 AC 277 ms
83,384 KB
testcase_10 AC 333 ms
94,500 KB
testcase_11 AC 352 ms
88,292 KB
testcase_12 AC 382 ms
86,796 KB
testcase_13 AC 358 ms
93,632 KB
testcase_14 AC 357 ms
93,820 KB
testcase_15 AC 368 ms
91,596 KB
testcase_16 AC 374 ms
92,276 KB
testcase_17 AC 372 ms
91,936 KB
testcase_18 AC 327 ms
92,012 KB
testcase_19 AC 74 ms
71,292 KB
testcase_20 AC 73 ms
71,080 KB
testcase_21 AC 75 ms
71,312 KB
testcase_22 AC 74 ms
71,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))

U = [0 for _ in range(n)]
L = [0 for _ in range(n)]
U[0] = L[0] = 1
u = l = 1
for i in range(1, n):
    if A[i] >= A[i - 1]:
        U[i] = 1
        u += 1
    else:
        U[i] -= u
        u = 0
    if A[i] <= A[i - 1]:
        L[i] = 1
        l += 1
    else:
        L[i] -= l
        l = 0
for i in range(1, n):
    U[i] += U[i - 1]
    L[i] += L[i - 1]

q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    ANS = [0, 0]
    if U[r] - U[l] == r - l:
        ANS[0] = 1
    if L[r] - L[l] == r - l:
        ANS[1] = 1
    print(*ANS)
0