結果

問題 No.33 アメーバがたくさん
ユーザー cielciel
提出日時 2014-11-28 15:23:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,105 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 12,084 KB
実行使用メモリ 10,120 KB
最終ジャッジ日時 2023-10-24 17:42:53
合計ジャッジ時間 1,063 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python
#coding:utf-8
#derived from checkio painting-wall (presented by me)
#http://www.checkio.org/mission/painting-wall/share/8a0e0061de3ff95664776d904d309e57/
import bisect

def checkio(data):
	ret_idx=0
	result=0
	se=[]
	for l,r in data:
		ret_idx+=1
		right_idx=bisect.bisect_left(se,(l,0)) #l <= se[right_idx][0]
		if right_idx!=0:
			left_idx=right_idx-1
			if l<=se[left_idx][1]: # overlap with left
				l=se[left_idx][0]
				r=max(r,se[left_idx][1])
				result-=se[left_idx][1]-se[left_idx][0]+1
				se.pop(left_idx)
				right_idx-=1
		while right_idx<len(se) and se[right_idx][0]<=r: # overlap with right
			r=max(r,se[right_idx][1])
			result-=se[right_idx][1]-se[right_idx][0]+1
			se.pop(right_idx)
		result+=r-l+1
		se.insert(right_idx,(l,r))
	return result

if __name__ == '__main__':
	from collections import defaultdict
	import sys
	dic=defaultdict(list)
	n,d,t=[int(e) for e in raw_input().split()]
	for e in map(int,raw_input().split()):
		mod=e%d
		dic[mod].append(((e-mod)/d-t,(e-mod)/d+t))
	print(sum(checkio(v) for k,v in dic.items()))
0