結果
問題 | No.905 Sorted? |
ユーザー |
![]() |
提出日時 | 2019-10-11 22:19:45 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 495 ms / 2,000 ms |
コード長 | 1,013 bytes |
コンパイル時間 | 96 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 38,984 KB |
最終ジャッジ日時 | 2024-11-25 07:56:54 |
合計ジャッジ時間 | 6,357 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
import sys input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) Q = int(input()) Query = [list(map(int, input().split())) for _ in range(Q)] increase = [0 for _ in range(N)] l = 0 r = 0 while l < N-1: if r < N-1: if A[r] <= A[r+1]: r += 1 elif l == r: increase[l] = r r += 1 l += 1 else: increase[l] = r l += 1 else: increase[l] = r l += 1 decrease = [0 for _ in range(N)] l = 0 r = 0 while l < N-1: if r < N-1: if A[r] >= A[r+1]: r += 1 elif l == r: decrease[l] = r r += 1 l += 1 else: decrease[l] = r l += 1 else: decrease[l] = r l += 1 increase[N-1] = N-1 decrease[N-1] = N-1 for l, r in Query: if r <= increase[l]: a = 1 else: a = 0 if r <= decrease[l]: b = 1 else: b = 0 print(a, b)