結果

問題 No.905 Sorted?
ユーザー yomo3yomo3
提出日時 2020-02-25 17:04:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 892 ms / 2,000 ms
コード長 367 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 22,604 KB
最終ジャッジ日時 2024-04-21 13:42:30
合計ジャッジ時間 10,661 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
10,752 KB
testcase_01 AC 32 ms
10,752 KB
testcase_02 AC 32 ms
10,752 KB
testcase_03 AC 30 ms
10,752 KB
testcase_04 AC 30 ms
10,880 KB
testcase_05 AC 35 ms
11,136 KB
testcase_06 AC 33 ms
10,880 KB
testcase_07 AC 45 ms
11,648 KB
testcase_08 AC 745 ms
16,436 KB
testcase_09 AC 495 ms
16,348 KB
testcase_10 AC 683 ms
22,336 KB
testcase_11 AC 761 ms
20,048 KB
testcase_12 AC 873 ms
19,448 KB
testcase_13 AC 769 ms
22,604 KB
testcase_14 AC 768 ms
21,956 KB
testcase_15 AC 892 ms
21,048 KB
testcase_16 AC 859 ms
20,444 KB
testcase_17 AC 862 ms
20,424 KB
testcase_18 AC 648 ms
20,548 KB
testcase_19 AC 31 ms
10,752 KB
testcase_20 AC 30 ms
10,752 KB
testcase_21 AC 30 ms
10,752 KB
testcase_22 AC 30 ms
10,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

gt = [0] * N
lt = [0] * N
for i in range(1, N):
        gt[i] = gt[i-1] + (A[i] > A[i-1])
        lt[i] = lt[i-1] + (A[i] < A[i-1])

f = lambda l, r: int(lt[r]-lt[l] == 0)
g = lambda l, r: int(gt[r]-gt[l] == 0)

Q = int(input())
for i in range(Q):
    L, R = map(int, input().split())
    print(f(L, R), g(L, R)) 
0