結果
| 問題 | No.905 Sorted? | 
| コンテスト | |
| ユーザー |  FromBooska | 
| 提出日時 | 2023-08-10 10:43:38 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 349 ms / 2,000 ms | 
| コード長 | 833 bytes | 
| コンパイル時間 | 1,083 ms | 
| コンパイル使用メモリ | 81,920 KB | 
| 実行使用メモリ | 105,344 KB | 
| 最終ジャッジ日時 | 2024-11-16 13:53:49 | 
| 合計ジャッジ時間 | 7,114 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
ソースコード
# 2つの異なることを調べたいので別々に調べる
N = int(input())
A = list(map(int, input().split()))
increase = [0]*N
decrease = [0]*N
for i in range(1, N):
    if A[i] >= A[i-1]:
        increase[i] = 1
    if A[i] <= A[i-1]:
        decrease[i] = 1
#print(increase)
#print(decrease)
increase_cumu = [0]
temp = 0
for i in range(N):
    temp += increase[i]
    increase_cumu.append(temp)
decrease_cumu = [0]
temp = 0
for i in range(N):
    temp += decrease[i]
    decrease_cumu.append(temp)
    
#print(increase_cumu)
#print(decrease_cumu)
Q = int(input())
for q in range(Q):
    l, r = map(int, input().split())
    ans1 = 0
    if increase_cumu[r+1]-increase_cumu[l+1] == r-l:
        ans1 = 1
    ans2 = 0
    if decrease_cumu[r+1]-decrease_cumu[l+1] == r-l:
        ans2 = 1
    print(ans1, ans2)
        
            
            
            
        