結果

問題 No.905 Sorted?
ユーザー pluto77
提出日時 2019-11-05 11:50:20
言語 Python2
(2.7.18)
結果
AC  
実行時間 490 ms / 2,000 ms
コード長 422 bytes
コンパイル時間 558 ms
コンパイル使用メモリ 7,068 KB
実行使用メモリ 19,628 KB
最終ジャッジ日時 2024-09-15 00:01:00
合計ジャッジ時間 6,572 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki905

n=int(raw_input())
a=map(int,raw_input().split())
inc=[0]*n
dec=[0]*n
cnt=0
for i in range(1,n):
 if a[i]-a[i-1]>=0:
  cnt+=1
  inc[i]=cnt
 else:
  cnt=0
cnt=0
for i in range(1,n):
 if a[i]-a[i-1]<=0:
  cnt+=1
  dec[i]=cnt
 else:
  cnt=0
q=int(raw_input())
for i in range(q):
 l,r=map(int,raw_input().split())
 res=[0,0]
 if inc[r]-inc[l]==r-l:
  res[0]=1
 if dec[r]-dec[l]==r-l:
  res[1]=1
 print res[0],res[1]
0