結果

問題 No.905 Sorted?
ユーザー ttrttr
提出日時 2020-02-02 20:19:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 764 ms / 2,000 ms
コード長 547 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 11,920 KB
実行使用メモリ 23,532 KB
最終ジャッジ日時 2023-10-19 01:25:39
合計ジャッジ時間 11,292 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,092 KB
testcase_01 AC 30 ms
10,096 KB
testcase_02 AC 29 ms
10,092 KB
testcase_03 AC 30 ms
10,092 KB
testcase_04 AC 30 ms
10,092 KB
testcase_05 AC 35 ms
10,472 KB
testcase_06 AC 32 ms
10,308 KB
testcase_07 AC 42 ms
11,112 KB
testcase_08 AC 620 ms
16,552 KB
testcase_09 AC 411 ms
15,420 KB
testcase_10 AC 566 ms
21,292 KB
testcase_11 AC 641 ms
19,008 KB
testcase_12 AC 733 ms
18,236 KB
testcase_13 AC 656 ms
23,532 KB
testcase_14 AC 643 ms
23,524 KB
testcase_15 AC 745 ms
19,268 KB
testcase_16 AC 764 ms
22,284 KB
testcase_17 AC 732 ms
21,584 KB
testcase_18 AC 554 ms
21,584 KB
testcase_19 AC 29 ms
10,092 KB
testcase_20 AC 31 ms
10,092 KB
testcase_21 AC 30 ms
10,092 KB
testcase_22 AC 29 ms
10,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = [int(a) for a in input().split()]

F = [0]*N
f = 1
G = [0]*N
g = 1
for i in range(N-1):
    if A[i+1] >= A[i]:
        F[i] = f
        F[i+1] = f
    else:
        f += 1
    if A[i+1] <= A[i]:
        G[i] = g
        G[i+1] = g
    else:
        g += 1

Q = int(input())
for _ in range(Q):
    l,r = map(int, input().split())
    if l == r:
        print("1 1")
        continue
    f = 0
    g = 0
    if F[l] == F[r] and F[l] > 0:
        f = 1
    if G[l] == G[r] and G[l] > 0:
        g = 1
    print(str(f)+" "+str(g))
0