結果

問題 No.905 Sorted?
ユーザー maspy
提出日時 2020-01-29 09:41:33
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 258 ms / 2,000 ms
コード長 550 bytes
コンパイル時間 221 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 35,520 KB
最終ジャッジ日時 2024-09-15 20:11:40
合計ジャッジ時間 5,549 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
A = list(map(int,readline().split()))
Q = int(readline())
m = map(int,read().split())
LR = zip(m,m)

incr = [0] * N
decr = [0] * N
for i,(x,y) in enumerate(zip(A,A[1:]),1):
    incr[i] = incr[i-1] if x <= y else i
    decr[i] = decr[i-1] if x >= y else i

answer = []
for L,R in LR:
    f = 1 if incr[R] <= L else 0
    g = 1 if decr[R] <= L else 0
    answer.append('{} {}'.format(f,g))

print('\n'.join(answer))
0