結果

問題 No.905 Sorted?
ユーザー hedwig100hedwig100
提出日時 2020-04-12 13:27:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 699 ms / 2,000 ms
コード長 995 bytes
コンパイル時間 353 ms
コンパイル使用メモリ 11,840 KB
実行使用メモリ 23,656 KB
最終ジャッジ日時 2023-10-22 01:12:10
合計ジャッジ時間 9,407 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,232 KB
testcase_01 AC 31 ms
10,236 KB
testcase_02 AC 31 ms
10,232 KB
testcase_03 AC 31 ms
10,232 KB
testcase_04 AC 30 ms
10,232 KB
testcase_05 AC 35 ms
10,624 KB
testcase_06 AC 32 ms
10,472 KB
testcase_07 AC 43 ms
11,300 KB
testcase_08 AC 600 ms
16,672 KB
testcase_09 AC 406 ms
15,856 KB
testcase_10 AC 543 ms
22,928 KB
testcase_11 AC 602 ms
20,140 KB
testcase_12 AC 699 ms
19,296 KB
testcase_13 AC 611 ms
23,656 KB
testcase_14 AC 618 ms
23,644 KB
testcase_15 AC 689 ms
20,880 KB
testcase_16 AC 692 ms
23,356 KB
testcase_17 AC 684 ms
21,704 KB
testcase_18 AC 508 ms
21,704 KB
testcase_19 AC 31 ms
10,232 KB
testcase_20 AC 30 ms
10,232 KB
testcase_21 AC 30 ms
10,232 KB
testcase_22 AC 30 ms
10,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from collections import deque
from heapq import heapify,heappush,heappop

def main():
    n = int(input())
    a = list(map(int,input().split()))
    inc = [0]
    dec = [0]
    for i in range(n - 1):
        if a[i] == a[i + 1]:
            inc.append(1)
            dec.append(1)
        elif a[i] < a[i + 1]:
            inc.append(1)
            dec.append(0)
        else:
            inc.append(0)
            dec.append(1)
    
    for i in range(n - 1):
        inc[i + 1] += inc[i]
        dec[i + 1] += dec[i]
    
    q = int(input())
    for _ in range(q):
        l,r = map(int,input().split())
        if r == l:
            print(1,1)
        else:
            ans = [0,0]
            if inc[r] - inc[l] == r - l:
                ans[0] = 1
            if dec[r] - dec[l] == r - l:
                ans[1] = 1
            print(*ans)

if __name__ == '__main__':
    main()
0