結果

問題 No.905 Sorted?
ユーザー tktk_snsntktk_snsn
提出日時 2021-05-25 21:36:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 402 ms / 2,000 ms
コード長 449 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 21,664 KB
最終ジャッジ日時 2024-04-22 13:08:15
合計ジャッジ時間 6,669 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 30 ms
10,624 KB
testcase_02 AC 30 ms
10,624 KB
testcase_03 AC 35 ms
10,624 KB
testcase_04 AC 30 ms
10,752 KB
testcase_05 AC 35 ms
11,008 KB
testcase_06 AC 32 ms
10,880 KB
testcase_07 AC 40 ms
11,648 KB
testcase_08 AC 348 ms
16,272 KB
testcase_09 AC 267 ms
15,672 KB
testcase_10 AC 362 ms
19,720 KB
testcase_11 AC 350 ms
18,156 KB
testcase_12 AC 389 ms
17,376 KB
testcase_13 AC 380 ms
21,664 KB
testcase_14 AC 387 ms
21,660 KB
testcase_15 AC 398 ms
18,492 KB
testcase_16 AC 395 ms
20,108 KB
testcase_17 AC 402 ms
19,972 KB
testcase_18 AC 316 ms
20,096 KB
testcase_19 AC 30 ms
10,624 KB
testcase_20 AC 31 ms
10,624 KB
testcase_21 AC 30 ms
10,752 KB
testcase_22 AC 29 ms
10,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = list(map(int, input().split()))

F = [0] * N
G = [0] * N

mx = 0
my = 0
for i in range(1, N):
    if A[i-1] > A[i]:
        mx += 1
    if A[i-1] < A[i]:
        my += 1
    F[i] = mx
    G[i] = my

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    ans1 = int(F[l] == F[r])
    ans2 = int(G[l] == G[r])
    print(ans1, ans2)
0