Submission #32546438


Source Code Expand

import sys
input=sys.stdin.readline

n=int(input())
cnt=[0]*(200005)
for i in range(n):
	x,y=map(int,input().split())
	cnt[x]+=1
	cnt[y]-=1

for i in range(len(cnt)-1):
	cnt[i+1]+=cnt[i]

ans=[]
ok=0
for i in range(1,len(cnt)):
	if cnt[i]>=1 and ok==0:
		ok=i
	elif cnt[i]==0 and ok>0:
		ans.append((ok,i))
		ok=0

for x,y in ans:
	print(x,y)

Submission Info

Submission Time
Task D - Union of Interval
User sangonana
Language PyPy3 (7.3.0)
Score 400
Code Size 365 Byte
Status AC
Exec Time 149 ms
Memory 80360 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 24
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
random_01.txt AC 146 ms 75268 KiB
random_02.txt AC 87 ms 75120 KiB
random_03.txt AC 149 ms 75676 KiB
random_04.txt AC 133 ms 75528 KiB
random_05.txt AC 139 ms 75320 KiB
random_06.txt AC 148 ms 75372 KiB
random_07.txt AC 131 ms 75300 KiB
random_08.txt AC 100 ms 74912 KiB
random_09.txt AC 149 ms 75632 KiB
random_10.txt AC 133 ms 75464 KiB
random_11.txt AC 116 ms 75228 KiB
random_12.txt AC 57 ms 65488 KiB
random_13.txt AC 138 ms 77632 KiB
random_14.txt AC 133 ms 76700 KiB
random_15.txt AC 120 ms 77012 KiB
random_16.txt AC 141 ms 75256 KiB
random_17.txt AC 135 ms 75300 KiB
random_18.txt AC 104 ms 75292 KiB
random_19.txt AC 141 ms 75288 KiB
random_20.txt AC 106 ms 75280 KiB
random_21.txt AC 133 ms 80360 KiB
random_22.txt AC 123 ms 78776 KiB
sample_01.txt AC 56 ms 65308 KiB
sample_02.txt AC 56 ms 65176 KiB