結果

問題 No.905 Sorted?
ユーザー 双六双六
提出日時 2020-08-19 04:22:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 218 ms / 2,000 ms
コード長 785 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 114,560 KB
最終ジャッジ日時 2024-04-20 08:10:22
合計ジャッジ時間 5,043 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
53,504 KB
testcase_01 AC 48 ms
54,144 KB
testcase_02 AC 49 ms
53,632 KB
testcase_03 AC 48 ms
53,888 KB
testcase_04 AC 50 ms
53,760 KB
testcase_05 AC 67 ms
65,664 KB
testcase_06 AC 61 ms
63,232 KB
testcase_07 AC 80 ms
72,832 KB
testcase_08 AC 197 ms
87,552 KB
testcase_09 AC 170 ms
89,856 KB
testcase_10 AC 196 ms
114,176 KB
testcase_11 AC 206 ms
104,960 KB
testcase_12 AC 218 ms
101,120 KB
testcase_13 AC 197 ms
102,400 KB
testcase_14 AC 209 ms
100,736 KB
testcase_15 AC 198 ms
113,920 KB
testcase_16 AC 191 ms
114,176 KB
testcase_17 AC 194 ms
114,560 KB
testcase_18 AC 178 ms
114,048 KB
testcase_19 AC 47 ms
53,504 KB
testcase_20 AC 47 ms
53,376 KB
testcase_21 AC 48 ms
53,376 KB
testcase_22 AC 47 ms
53,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	A = getlist()
	Q = int(input())
	F = []
	G = []
	for i in range(N - 1):
		if A[i + 1] >= A[i]:
			F.append(1)
		else:
			F.append(0)
		if A[i + 1] <= A[i]:
			G.append(1)
		else:
			G.append(0)

	Fsum = [0]
	Gsum = [0]
	for i in range(N - 1):
		Fsum.append(Fsum[-1] + F[i])
		Gsum.append(Gsum[-1] + G[i])

	for i in range(Q):
		l, r = getlist()
		if Fsum[r] - Fsum[l] == r - l:
			ans1 = 1
		else:
			ans1 = 0
		if Gsum[r] - Gsum[l] == r - l:
			ans2 = 1
		else:
			ans2 = 0

		print(ans1, ans2)




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