結果

問題 No.3553 Good Quartet
コンテスト
ユーザー lif4635
提出日時 2026-05-21 19:48:40
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 719 ms / 2,000 ms
コード長 549 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 745 ms
コンパイル使用メモリ 84,736 KB
実行使用メモリ 141,448 KB
最終ジャッジ日時 2026-05-22 21:50:02
合計ジャッジ時間 9,748 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_1
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from  collections import defaultdict

n, q = map(int, input().split())
s1 = defaultdict(int)
s2 = defaultdict(int)

ans = 0
def add(x, f = 1):
	global ans
	for d in (1, 5, 7, 11):
		if x % d == 0:
			if s1[x//d] == 4: ans -= 1
			s1[x//d] += f
			if s1[x//d] == 4: ans += 1
	
	for d in (1, 11, 19, 29):
		if x % d == 0:
			if s2[x//d] == 4: ans -= 1
			s2[x//d] += f
			if s2[x//d] == 4: ans += 1


for x in map(int, input().split()):
	add(x)

for _ in range(q):
	t, x = map(int, input().split())
	if t == 1:
		add(x)
	else:
		add(x, -1)
	print(ans)
0