結果

問題 No.905 Sorted?
ユーザー hir355
提出日時 2020-04-03 17:43:16
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 970 ms / 2,000 ms
コード長 473 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 22,820 KB
最終ジャッジ日時 2024-07-03 00:59:05
合計ジャッジ時間 11,699 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))
p = [0] * n
q = [0] * n
for i in range(n - 1):
    if a[i] <= a[i + 1]:
        p[i + 1] = 1
    if a[i] >= a[i + 1]:
        q[i + 1] = 1
    p[i + 1] += p[i]
    q[i + 1] += q[i]
qe = int(input())
for _ in range(qe):
    l, r = map(int, input().split())
    if p[r] - p[l] == r - l:
        print(1, end=' ')
    else:
        print(0, end=' ')
    if q[r] - q[l] == r - l:
        print(1)
    else:
        print(0)
0