結果
| 問題 | No.905 Sorted? | 
| コンテスト | |
| ユーザー |  takakin | 
| 提出日時 | 2020-06-15 22:38:57 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 373 ms / 2,000 ms | 
| コード長 | 437 bytes | 
| コンパイル時間 | 83 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 24,348 KB | 
| 最終ジャッジ日時 | 2024-07-03 11:35:28 | 
| 合計ジャッジ時間 | 5,794 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
ソースコード
import sys,heapq
input = sys.stdin.buffer.readline
n=int(input())
A=[int(i) for i in input().split()]
I,D=[0],[0]
for i in range(1,n):
  if A[i]>=A[i-1]:
    I.append(I[-1]+1)
  else:
    I.append(I[-1])
  if A[i]<=A[i-1]:
    D.append(D[-1]+1)
  else:
    D.append(D[-1])
q=int(input())
for _ in range(q):
  l,r=map(int,input().split())
  ans1,ans2=0,0
  if r-l==I[r]-I[l]:
    ans1=1
  if r-l==D[r]-D[l]:
    ans2=1
  print(ans1,ans2)
            
            
            
        