結果

問題 No.610 区間賞(Section Award)
ユーザー 双六双六
提出日時 2020-07-26 15:58:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 435 ms / 2,000 ms
コード長 852 bytes
コンパイル時間 1,174 ms
コンパイル使用メモリ 86,596 KB
実行使用メモリ 115,584 KB
最終ジャッジ日時 2023-09-11 02:06:17
合計ジャッジ時間 15,027 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,468 KB
testcase_01 AC 91 ms
71,372 KB
testcase_02 AC 95 ms
71,632 KB
testcase_03 AC 93 ms
71,464 KB
testcase_04 AC 90 ms
71,480 KB
testcase_05 AC 90 ms
71,628 KB
testcase_06 AC 108 ms
77,392 KB
testcase_07 AC 99 ms
76,264 KB
testcase_08 AC 101 ms
77,188 KB
testcase_09 AC 99 ms
76,284 KB
testcase_10 AC 103 ms
77,272 KB
testcase_11 AC 104 ms
77,188 KB
testcase_12 AC 91 ms
71,312 KB
testcase_13 AC 104 ms
77,436 KB
testcase_14 AC 102 ms
77,212 KB
testcase_15 AC 101 ms
77,060 KB
testcase_16 AC 100 ms
77,224 KB
testcase_17 AC 101 ms
76,924 KB
testcase_18 AC 97 ms
76,756 KB
testcase_19 AC 150 ms
81,952 KB
testcase_20 AC 404 ms
115,368 KB
testcase_21 AC 137 ms
79,820 KB
testcase_22 AC 295 ms
102,544 KB
testcase_23 AC 123 ms
77,828 KB
testcase_24 AC 167 ms
83,420 KB
testcase_25 AC 115 ms
77,516 KB
testcase_26 AC 223 ms
91,580 KB
testcase_27 AC 413 ms
115,420 KB
testcase_28 AC 367 ms
110,020 KB
testcase_29 AC 282 ms
99,132 KB
testcase_30 AC 341 ms
106,584 KB
testcase_31 AC 211 ms
91,112 KB
testcase_32 AC 374 ms
111,124 KB
testcase_33 AC 133 ms
79,812 KB
testcase_34 AC 411 ms
115,060 KB
testcase_35 AC 231 ms
93,140 KB
testcase_36 AC 392 ms
115,104 KB
testcase_37 AC 334 ms
106,276 KB
testcase_38 AC 155 ms
82,476 KB
testcase_39 AC 415 ms
115,328 KB
testcase_40 AC 418 ms
115,408 KB
testcase_41 AC 415 ms
115,292 KB
testcase_42 AC 416 ms
115,392 KB
testcase_43 AC 415 ms
115,320 KB
testcase_44 AC 380 ms
107,052 KB
testcase_45 AC 431 ms
115,356 KB
testcase_46 AC 435 ms
115,584 KB
testcase_47 AC 347 ms
109,620 KB
testcase_48 AC 329 ms
106,460 KB
testcase_49 AC 347 ms
109,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

class BIT:
	def __init__(self, N):
		self.size = N
		self.tree = [0] * (N + 1)

	def sum(self, t):
		s = 0
		while t > 0:
			s += self.tree[t]
			t -= t & -t
		return s

	def add(self, t, x):
		while t <= self.size:
			self.tree[t] += x
			t += t & -t

#処理内容
def main():
	N = int(input())
	A = getlist()
	B = getlist()
	conv = [[A[i], i + 1] for i in range(N)]
	conv.sort()
	# print(conv)
	B2 = [conv[B[i] - 1][1] for i in range(N)]
	# print(B2)
	ans = []
	bit = BIT(N + 1)
	for i in range(N):
		bit.add(B2[i], 1)
		if bit.sum(B2[i]) == i + 1:
			ans.append(B[i])

	ans.sort()
	for i in ans:
		print(i)

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