結果

問題 No.905 Sorted?
コンテスト
ユーザー pto8913
提出日時 2019-10-11 22:49:55
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 735 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 542 ms
コンパイル使用メモリ 20,700 KB
実行使用メモリ 25,588 KB
最終ジャッジ日時 2026-05-19 22:05:12
合計ジャッジ時間 7,415 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 8 TLE * 1 -- * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))

def main():
  n = ni()
  a = na()

  q = ni()
  for _ in range(q):
    l, r = na()
    gcnt = 0
    lcnt = 0
    ecnt = 0
    for i in range(l, r):
      if a[i] <= a[i+1]:
        gcnt += 1
      if a[i] >= a[i+1]:
        lcnt += 1
      if a[i] == a[i+1]:
        ecnt += 1
    c = r - l
    if gcnt == c:
      if ecnt == c:
        print(1, 1)
        continue
      print(1, 0)
    if lcnt == c:
      if ecnt == c:
        print(1, 1)
        continue
      print(0, 1)
    if ecnt == c:
      print(1, 1)
    if gcnt != c and lcnt != c and ecnt != c:
      print(0, 0)

main()
0