結果

問題 No.905 Sorted?
ユーザー takakintakakin
提出日時 2020-06-15 22:38:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 335 ms / 2,000 ms
コード長 437 bytes
コンパイル時間 69 ms
コンパイル使用メモリ 10,888 KB
実行使用メモリ 21,488 KB
最終ジャッジ日時 2023-09-16 10:36:03
合計ジャッジ時間 4,839 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,988 KB
testcase_01 AC 17 ms
8,008 KB
testcase_02 AC 15 ms
7,968 KB
testcase_03 AC 16 ms
8,004 KB
testcase_04 AC 15 ms
8,024 KB
testcase_05 AC 19 ms
8,620 KB
testcase_06 AC 17 ms
8,408 KB
testcase_07 AC 23 ms
9,108 KB
testcase_08 AC 261 ms
13,308 KB
testcase_09 AC 179 ms
13,192 KB
testcase_10 AC 265 ms
17,588 KB
testcase_11 AC 278 ms
17,180 KB
testcase_12 AC 303 ms
16,720 KB
testcase_13 AC 298 ms
19,020 KB
testcase_14 AC 300 ms
19,056 KB
testcase_15 AC 321 ms
16,616 KB
testcase_16 AC 335 ms
21,488 KB
testcase_17 AC 326 ms
18,576 KB
testcase_18 AC 260 ms
18,464 KB
testcase_19 AC 16 ms
8,120 KB
testcase_20 AC 16 ms
8,088 KB
testcase_21 AC 15 ms
7,968 KB
testcase_22 AC 16 ms
7,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0