結果
問題 |
No.905 Sorted?
|
ユーザー |
|
提出日時 | 2020-04-12 13:27:32 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 801 ms / 2,000 ms |
コード長 | 995 bytes |
コンパイル時間 | 180 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 23,968 KB |
最終ジャッジ日時 | 2024-09-22 02:33:12 |
合計ジャッジ時間 | 9,898 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
MOD = 10 ** 9 + 7 INF = 10 ** 10 import sys sys.setrecursionlimit(100000000) dy = (-1,0,1,0) dx = (0,1,0,-1) from collections import deque from heapq import heapify,heappush,heappop def main(): n = int(input()) a = list(map(int,input().split())) inc = [0] dec = [0] for i in range(n - 1): if a[i] == a[i + 1]: inc.append(1) dec.append(1) elif a[i] < a[i + 1]: inc.append(1) dec.append(0) else: inc.append(0) dec.append(1) for i in range(n - 1): inc[i + 1] += inc[i] dec[i + 1] += dec[i] q = int(input()) for _ in range(q): l,r = map(int,input().split()) if r == l: print(1,1) else: ans = [0,0] if inc[r] - inc[l] == r - l: ans[0] = 1 if dec[r] - dec[l] == r - l: ans[1] = 1 print(*ans) if __name__ == '__main__': main()