結果

問題 No.905 Sorted?
ユーザー 👑 H20H20
提出日時 2021-10-30 19:06:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 362 ms / 2,000 ms
コード長 485 bytes
コンパイル時間 737 ms
コンパイル使用メモリ 82,340 KB
実行使用メモリ 103,552 KB
最終ジャッジ日時 2024-04-16 16:26:57
合計ジャッジ時間 6,944 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
52,480 KB
testcase_01 AC 41 ms
53,248 KB
testcase_02 AC 40 ms
52,224 KB
testcase_03 AC 39 ms
52,736 KB
testcase_04 AC 41 ms
52,224 KB
testcase_05 AC 60 ms
66,432 KB
testcase_06 AC 51 ms
62,720 KB
testcase_07 AC 73 ms
73,088 KB
testcase_08 AC 345 ms
88,700 KB
testcase_09 AC 259 ms
86,912 KB
testcase_10 AC 313 ms
98,688 KB
testcase_11 AC 336 ms
96,384 KB
testcase_12 AC 361 ms
93,440 KB
testcase_13 AC 338 ms
95,104 KB
testcase_14 AC 341 ms
94,824 KB
testcase_15 AC 362 ms
102,272 KB
testcase_16 AC 357 ms
103,220 KB
testcase_17 AC 354 ms
103,552 KB
testcase_18 AC 323 ms
103,100 KB
testcase_19 AC 39 ms
52,096 KB
testcase_20 AC 39 ms
52,480 KB
testcase_21 AC 39 ms
52,096 KB
testcase_22 AC 39 ms
52,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
N = int(input())
A = list(map(int, input().split())) 
U = [1]*N
D = [1]*N
for i in range(1,N):
    if A[i]<A[i-1]:
        U[i]=0
for i in range(1,N):
    if A[i]>A[i-1]:
        D[i]=0
UAC = list(itertools.accumulate(U))
DAC = list(itertools.accumulate(D))


Q = int(input())
for _ in range(Q):
    l,r = map(int, input().split())
    if l==r:
        print(1,1)
    else:
        f = int(r-l == UAC[r]-UAC[l])
        g = int(r-l == DAC[r]-DAC[l])
        print(f,g)
0