結果

問題 No.905 Sorted?
ユーザー FromBooskaFromBooska
提出日時 2023-08-10 10:43:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 369 ms / 2,000 ms
コード長 833 bytes
コンパイル時間 363 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 105,472 KB
最終ジャッジ日時 2024-04-28 04:08:45
合計ジャッジ時間 6,863 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
52,352 KB
testcase_01 AC 50 ms
52,736 KB
testcase_02 AC 49 ms
52,096 KB
testcase_03 AC 45 ms
52,096 KB
testcase_04 AC 44 ms
52,224 KB
testcase_05 AC 71 ms
65,408 KB
testcase_06 AC 60 ms
62,592 KB
testcase_07 AC 83 ms
72,704 KB
testcase_08 AC 363 ms
88,704 KB
testcase_09 AC 270 ms
86,232 KB
testcase_10 AC 318 ms
105,472 KB
testcase_11 AC 339 ms
96,640 KB
testcase_12 AC 369 ms
93,696 KB
testcase_13 AC 337 ms
94,336 KB
testcase_14 AC 356 ms
94,848 KB
testcase_15 AC 361 ms
102,528 KB
testcase_16 AC 368 ms
103,680 KB
testcase_17 AC 361 ms
103,680 KB
testcase_18 AC 294 ms
103,104 KB
testcase_19 AC 39 ms
51,840 KB
testcase_20 AC 39 ms
51,840 KB
testcase_21 AC 39 ms
51,840 KB
testcase_22 AC 40 ms
52,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 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)
        


0