Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
B"Your math teacher gave you the following problem: There are n segments on the x -axis, [l_1; r_1], [l_2; r_2], ldots, [l_n; r_n] . The segment [l; r] includes the bounds, i.e. it is a set of such x that l <= x <= r . The length of the segment [l; r] is equal to r - l . Two segments [a; b] and [c; d] have a common point (intersect) if there exists x that a <= q x <= q b and c <= q x <= q d . For example, [2; 5] and [3; 10] have a common point, but [5; 6] and [1; 4] don't have. You should add one segment, which has at least one common point with each of the given segments and as short as possible (i.e. has minimal length). The required segment can degenerate to be a point (i.e a segment with length zero). The added segment may or may not be among the given n segments. In other words, you need to find a segment [a; b] , such that [a; b] and every [l_i; r_i] have a common point for each i , and b-a is minimal. The first line contains integer number t ( 1 <= t <= 100 ) -- the number of test cases in the input. Then t test cases follow. The first line of each test case contains one integer n ( 1 <= n <= 10^{5} ) -- the number of segments. The following n lines contain segment descriptions: the i -th of them contains two integers l_i,r_i ( 1 <= l_i <= r_i <= 10^{9} ). The sum of all values n over all the test cases in the input doesn't exceed 10^5 . For each test case, output one integer -- the smallest possible length of the segment which has at least one common point with all given segments. In the first test case of the example, we can choose the segment [5;7] as the answer. It is the shortest segment that has at least one common point with all given segments. "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
65734867 |
dblark |
A |
Nov. 26, 2019, 7:15 a.m. |
OK |
FPC |
TESTS |
21 |
62 |
0 |
|
1100 |
65635977 |
Nikita231 |
A |
Nov. 24, 2019, 8:39 a.m. |
OK |
FPC |
TESTS |
21 |
62 |
0 |
|
1100 |
65637616 |
dIm0N4eG |
A |
Nov. 24, 2019, 8:45 a.m. |
OK |
FPC |
TESTS |
21 |
62 |
204800 |
|
1100 |
65721240 |
Pocepko |
A |
Nov. 25, 2019, 7:12 p.m. |
OK |
FPC |
TESTS |
21 |
62 |
1024000 |
|
1100 |
65627248 |
Craspedacusta |
A |
Nov. 24, 2019, 8:12 a.m. |
OK |
FPC |
TESTS |
21 |
77 |
0 |
|
1100 |
65627189 |
LaSWeeG |
A |
Nov. 24, 2019, 8:11 a.m. |
OK |
FPC |
TESTS |
21 |
77 |
0 |
|
1100 |
65632049 |
StEpAn_123 |
A |
Nov. 24, 2019, 8:26 a.m. |
OK |
FPC |
TESTS |
21 |
77 |
307200 |
|
1100 |
68945516 |
SlavicG |
A |
Jan. 16, 2020, 4 p.m. |
OK |
GNU C11 |
TESTS |
21 |
46 |
0 |
|
1100 |
68945476 |
MoldovaIT |
A |
Jan. 16, 2020, 3:59 p.m. |
OK |
GNU C11 |
TESTS |
21 |
46 |
0 |
|
1100 |
66025219 |
akshatdalton |
A |
Nov. 30, 2019, 8:30 a.m. |
OK |
GNU C11 |
TESTS |
21 |
46 |
0 |
|
1100 |
68945406 |
lazybear |
A |
Jan. 16, 2020, 3:58 p.m. |
OK |
GNU C11 |
TESTS |
21 |
46 |
0 |
|
1100 |
68945457 |
Maxiapple |
A |
Jan. 16, 2020, 3:59 p.m. |
OK |
GNU C11 |
TESTS |
21 |
46 |
0 |
|
1100 |
68945461 |
ionboss |
A |
Jan. 16, 2020, 3:59 p.m. |
OK |
GNU C11 |
TESTS |
21 |
46 |
0 |
|
1100 |
65798956 |
_Tom_ |
A |
Nov. 27, 2019, 6:32 a.m. |
OK |
GNU C11 |
TESTS |
21 |
46 |
819200 |
|
1100 |
68945550 |
melnic.cristian |
A |
Jan. 16, 2020, 4:01 p.m. |
OK |
GNU C11 |
TESTS |
21 |
62 |
0 |
|
1100 |
68945431 |
influencer |
A |
Jan. 16, 2020, 3:58 p.m. |
OK |
GNU C11 |
TESTS |
21 |
62 |
0 |
|
1100 |
66601418 |
Mikhail___ |
A |
Dec. 10, 2019, 4:40 p.m. |
OK |
GNU C11 |
TESTS |
21 |
62 |
0 |
|
1100 |
66218716 |
pkh68 |
A |
Dec. 3, 2019, 10:03 a.m. |
OK |
GNU C++11 |
TESTS |
21 |
31 |
0 |
|
1100 |
66221402 |
luogu_bot2 |
A |
Dec. 3, 2019, 10:55 a.m. |
OK |
GNU C++11 |
TESTS |
21 |
31 |
0 |
|
1100 |
66674084 |
luogu_bot4 |
A |
Dec. 12, 2019, 10:35 a.m. |
OK |
GNU C++11 |
TESTS |
21 |
31 |
0 |
|
1100 |
65695115 |
Pengzhike |
A |
Nov. 25, 2019, 7:35 a.m. |
OK |
GNU C++11 |
TESTS |
21 |
31 |
0 |
|
1100 |
65793863 |
TangYida |
A |
Nov. 27, 2019, 2:16 a.m. |
OK |
GNU C++11 |
TESTS |
21 |
31 |
0 |
|
1100 |
65957992 |
luogu_bot1 |
A |
Nov. 29, 2019, 1:35 p.m. |
OK |
GNU C++11 |
TESTS |
21 |
31 |
0 |
|
1100 |
65956732 |
11235813213455 |
A |
Nov. 29, 2019, 1:08 p.m. |
OK |
GNU C++11 |
TESTS |
21 |
31 |
204800 |
|
1100 |
65730720 |
YLWang |
A |
Nov. 26, 2019, 4:53 a.m. |
OK |
GNU C++11 |
TESTS |
21 |
31 |
819200 |
|
1100 |
66013114 |
BeNoble |
A |
Nov. 30, 2019, 3:51 a.m. |
OK |
GNU C++11 |
TESTS |
21 |
31 |
2252800 |
|
1100 |
66163491 |
BeNoble |
A |
Dec. 2, 2019, 6:11 a.m. |
OK |
GNU C++11 |
TESTS |
21 |
31 |
2355200 |
|
1100 |
65947996 |
NoTeamName |
A |
Nov. 29, 2019, 9:32 a.m. |
OK |
GNU C++14 |
TESTS |
21 |
46 |
0 |
|
1100 |
65820536 |
gusion |
A |
Nov. 27, 2019, 10:16 a.m. |
OK |
GNU C++14 |
TESTS |
21 |
46 |
0 |
|
1100 |
68149655 |
9957 |
A |
Jan. 4, 2020, 6:21 a.m. |
OK |
GNU C++14 |
TESTS |
21 |
46 |
819200 |
|
1100 |
65918737 |
AmetKay |
A |
Nov. 28, 2019, 3:34 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
46 |
1638400 |
|
1100 |
65721783 |
ElGaseosonDelMimi |
A |
Nov. 25, 2019, 7:33 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
61 |
0 |
|
1100 |
69820860 |
shiliangzhi |
A |
Jan. 30, 2020, 7:48 a.m. |
OK |
GNU C++14 |
TESTS |
21 |
61 |
0 |
|
1100 |
65750031 |
JSZX11556 |
A |
Nov. 26, 2019, 1:41 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
61 |
0 |
|
1100 |
65723368 |
Temirulan |
A |
Nov. 25, 2019, 8:32 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
61 |
0 |
|
1100 |
65636910 |
fractal |
A |
Nov. 24, 2019, 8:42 a.m. |
OK |
GNU C++14 |
TESTS |
21 |
61 |
819200 |
|
1100 |
69731465 |
Ktwsz |
A |
Jan. 29, 2020, 1:38 p.m. |
OK |
GNU C++14 |
TESTS |
21 |
62 |
0 |
|
1100 |
65927688 |
ioyeoa |
A |
Nov. 28, 2019, 7:09 p.m. |
OK |
GNU C++17 |
TESTS |
21 |
31 |
819200 |
|
1100 |
66263031 |
.tx |
A |
Dec. 4, 2019, 9:13 a.m. |
OK |
GNU C++17 |
TESTS |
21 |
31 |
819200 |
|
1100 |
65687035 |
HatsuneMikuo |
A |
Nov. 25, 2019, 1:03 a.m. |
OK |
GNU C++17 |
TESTS |
21 |
31 |
1024000 |
|
1100 |
65629955 |
i999gera |
A |
Nov. 24, 2019, 8:20 a.m. |
OK |
GNU C++17 |
TESTS |
21 |
46 |
0 |
|
1100 |
65822154 |
XiaoWu |
A |
Nov. 27, 2019, 11:02 a.m. |
OK |
GNU C++17 |
TESTS |
21 |
46 |
0 |
|
1100 |
66302720 |
ledo |
A |
Dec. 5, 2019, 7:59 a.m. |
OK |
GNU C++17 |
TESTS |
21 |
46 |
819200 |
|
1100 |
65794668 |
VioletSaber |
A |
Nov. 27, 2019, 3:17 a.m. |
OK |
GNU C++17 |
TESTS |
21 |
61 |
0 |
|
1100 |
66235245 |
retnuHyssup |
A |
Dec. 3, 2019, 3:54 p.m. |
OK |
GNU C++17 |
TESTS |
21 |
61 |
0 |
|
1100 |
66615028 |
phuochuy2507 |
A |
Dec. 11, 2019, 2:56 a.m. |
OK |
GNU C++17 |
TESTS |
21 |
61 |
0 |
|
1100 |
67187542 |
kamilka.agliev |
A |
Dec. 19, 2019, 5:36 a.m. |
OK |
GNU C++17 |
TESTS |
21 |
61 |
0 |
|
1100 |
65628500 |
Shark_Eater |
A |
Nov. 24, 2019, 8:16 a.m. |
OK |
Java 11 |
TESTS |
21 |
202 |
0 |
|
1100 |
65627536 |
ivemari |
A |
Nov. 24, 2019, 8:13 a.m. |
OK |
Java 11 |
TESTS |
21 |
233 |
0 |
|
1100 |
65671304 |
IslamTalipovTop |
A |
Nov. 24, 2019, 4:03 p.m. |
OK |
Java 11 |
TESTS |
21 |
421 |
0 |
|
1100 |
66165191 |
OrangeJuice23 |
A |
Dec. 2, 2019, 7:11 a.m. |
OK |
Java 11 |
TESTS |
21 |
436 |
0 |
|
1100 |
69256074 |
noobie_code |
A |
Jan. 21, 2020, 3:41 p.m. |
OK |
Java 11 |
TESTS |
21 |
451 |
0 |
|
1100 |
65631504 |
Maves |
A |
Nov. 24, 2019, 8:24 a.m. |
OK |
Java 11 |
TESTS |
21 |
452 |
0 |
|
1100 |
65638361 |
DimaTomsk |
A |
Nov. 24, 2019, 8:48 a.m. |
OK |
Java 11 |
TESTS |
21 |
468 |
0 |
|
1100 |
65630742 |
0x2ee0 |
A |
Nov. 24, 2019, 8:22 a.m. |
OK |
Java 11 |
TESTS |
21 |
498 |
0 |
|
1100 |
65805564 |
Ad-007 |
A |
Nov. 27, 2019, 8:45 a.m. |
OK |
Java 8 |
TESTS |
21 |
109 |
0 |
|
1100 |
65730033 |
AnandOza |
A |
Nov. 26, 2019, 4:17 a.m. |
OK |
Java 8 |
TESTS |
21 |
140 |
0 |
|
1100 |
65630904 |
potatmen |
A |
Nov. 24, 2019, 8:22 a.m. |
OK |
Java 8 |
TESTS |
21 |
155 |
0 |
|
1100 |
68023988 |
thisbeit |
A |
Jan. 1, 2020, 3:34 a.m. |
OK |
Java 8 |
TESTS |
21 |
155 |
0 |
|
1100 |
67777101 |
igor_kz |
A |
Dec. 28, 2019, 9:26 a.m. |
OK |
Java 8 |
TESTS |
21 |
155 |
0 |
|
1100 |
65713323 |
4mda4mda |
A |
Nov. 25, 2019, 3:20 p.m. |
OK |
Java 8 |
TESTS |
21 |
155 |
0 |
|
1100 |
65698126 |
Shokersss |
A |
Nov. 25, 2019, 9:23 a.m. |
OK |
Java 8 |
TESTS |
21 |
155 |
0 |
|
1100 |
65630430 |
VladSwarrow |
A |
Nov. 24, 2019, 8:21 a.m. |
OK |
Java 8 |
TESTS |
21 |
155 |
0 |
|
1100 |
65628899 |
iliamikado |
A |
Nov. 24, 2019, 8:17 a.m. |
OK |
Java 8 |
TESTS |
21 |
155 |
0 |
|
1100 |
65628745 |
mikhaylov_boris |
A |
Nov. 24, 2019, 8:16 a.m. |
OK |
Java 8 |
TESTS |
21 |
170 |
0 |
|
1100 |
65632255 |
AlexPaniman |
A |
Nov. 24, 2019, 8:26 a.m. |
OK |
Kotlin |
TESTS |
21 |
373 |
307200 |
|
1100 |
65630445 |
kor.artemik2018 |
A |
Nov. 24, 2019, 8:21 a.m. |
OK |
Mono C# |
TESTS |
21 |
139 |
3072000 |
|
1100 |
65639699 |
vitaly_megabyte |
A |
Nov. 24, 2019, 8:53 a.m. |
OK |
Mono C# |
TESTS |
21 |
139 |
3891200 |
|
1100 |
65636215 |
Tema255 |
A |
Nov. 24, 2019, 8:40 a.m. |
OK |
Mono C# |
TESTS |
21 |
140 |
3072000 |
|
1100 |
65638579 |
_DAC_ |
A |
Nov. 24, 2019, 8:49 a.m. |
OK |
Mono C# |
TESTS |
21 |
155 |
7475200 |
|
1100 |
65630893 |
hooin |
A |
Nov. 24, 2019, 8:22 a.m. |
OK |
Mono C# |
TESTS |
21 |
171 |
6758400 |
|
1100 |
66638188 |
Halston1031 |
A |
Dec. 11, 2019, 1:44 p.m. |
OK |
MS C++ |
TESTS |
21 |
62 |
0 |
|
1100 |
65630354 |
godovald |
A |
Nov. 24, 2019, 8:21 a.m. |
OK |
MS C++ |
TESTS |
21 |
186 |
0 |
|
1100 |
66096282 |
vjudge3 |
A |
Dec. 1, 2019, 8 a.m. |
OK |
MS C++ |
TESTS |
21 |
187 |
0 |
|
1100 |
65636066 |
PavelBr |
A |
Nov. 24, 2019, 8:39 a.m. |
OK |
MS C++ |
TESTS |
21 |
187 |
0 |
|
1100 |
66310381 |
vjudge3 |
A |
Dec. 5, 2019, 11:12 a.m. |
OK |
MS C++ |
TESTS |
21 |
202 |
0 |
|
1100 |
66233126 |
vjudge5 |
A |
Dec. 3, 2019, 3:09 p.m. |
OK |
MS C++ |
TESTS |
21 |
202 |
0 |
|
1100 |
65628431 |
rtmztsv00 |
A |
Nov. 24, 2019, 8:15 a.m. |
OK |
MS C++ |
TESTS |
21 |
202 |
0 |
|
1100 |
65628788 |
MuzaIlya |
A |
Nov. 24, 2019, 8:16 a.m. |
OK |
MS C++ |
TESTS |
21 |
202 |
0 |
|
1100 |
65631286 |
coding_winner |
A |
Nov. 24, 2019, 8:24 a.m. |
OK |
MS C++ |
TESTS |
21 |
202 |
0 |
|
1100 |
65635595 |
yaroslavB |
A |
Nov. 24, 2019, 8:38 a.m. |
OK |
MS C++ |
TESTS |
21 |
202 |
0 |
|
1100 |
65633028 |
lp-3002 |
A |
Nov. 24, 2019, 8:29 a.m. |
OK |
MS C++ 2017 |
TESTS |
21 |
62 |
1228800 |
|
1100 |
65635126 |
denshlk |
A |
Nov. 24, 2019, 8:36 a.m. |
OK |
MS C++ 2017 |
TESTS |
21 |
77 |
0 |
|
1100 |
65626571 |
despairrr |
A |
Nov. 24, 2019, 8:10 a.m. |
OK |
MS C++ 2017 |
TESTS |
21 |
186 |
307200 |
|
1100 |
65627279 |
ViktorSM |
A |
Nov. 24, 2019, 8:12 a.m. |
OK |
MS C++ 2017 |
TESTS |
21 |
187 |
307200 |
|
1100 |
65635500 |
evgen.pog |
A |
Nov. 24, 2019, 8:37 a.m. |
OK |
MS C++ 2017 |
TESTS |
21 |
202 |
0 |
|
1100 |
65643850 |
Almost |
A |
Nov. 24, 2019, 9:11 a.m. |
OK |
MS C++ 2017 |
TESTS |
21 |
202 |
0 |
|
1100 |
65649757 |
Zallerrazion |
A |
Nov. 24, 2019, 9:41 a.m. |
OK |
MS C++ 2017 |
TESTS |
21 |
202 |
0 |
|
1100 |
66547686 |
IPRIT |
A |
Dec. 9, 2019, 1:47 p.m. |
OK |
MS C++ 2017 |
TESTS |
21 |
202 |
0 |
|
1100 |
66849967 |
yerzh |
A |
Dec. 14, 2019, 11:55 a.m. |
OK |
MS C++ 2017 |
TESTS |
21 |
202 |
0 |
|
1100 |
65642555 |
parampamparam |
A |
Nov. 24, 2019, 9:05 a.m. |
OK |
MS C++ 2017 |
TESTS |
21 |
202 |
0 |
|
1100 |
66309712 |
maxwader |
A |
Dec. 5, 2019, 10:56 a.m. |
OK |
PascalABC.NET |
TESTS |
21 |
467 |
512000 |
|
1100 |
65635444 |
VladislavOsokin |
A |
Nov. 24, 2019, 8:37 a.m. |
OK |
PascalABC.NET |
TESTS |
21 |
483 |
102400 |
|
1100 |
65639624 |
Pelmenkus |
A |
Nov. 24, 2019, 8:53 a.m. |
OK |
PascalABC.NET |
TESTS |
21 |
483 |
102400 |
|
1100 |
65635015 |
Goshix |
A |
Nov. 24, 2019, 8:36 a.m. |
OK |
PascalABC.NET |
TESTS |
21 |
498 |
102400 |
|
1100 |
65631911 |
Anya02 |
A |
Nov. 24, 2019, 8:25 a.m. |
OK |
PascalABC.NET |
TESTS |
21 |
498 |
2355200 |
|
1100 |
65634162 |
vaner29 |
A |
Nov. 24, 2019, 8:33 a.m. |
OK |
PascalABC.NET |
TESTS |
21 |
499 |
0 |
|
1100 |
65798213 |
gvozd_705 |
A |
Nov. 27, 2019, 6:07 a.m. |
OK |
PascalABC.NET |
TESTS |
21 |
514 |
0 |
|
1100 |
65648218 |
Zishka |
A |
Nov. 24, 2019, 9:34 a.m. |
OK |
PascalABC.NET |
TESTS |
21 |
514 |
102400 |
|
1100 |
65654862 |
Hellout |
A |
Nov. 24, 2019, 10:04 a.m. |
OK |
PascalABC.NET |
TESTS |
21 |
514 |
512000 |
|
1100 |
65649215 |
GeorgS |
A |
Nov. 24, 2019, 9:39 a.m. |
OK |
PascalABC.NET |
TESTS |
21 |
514 |
1228800 |
|
1100 |
65626341 |
nexus.chebykin |
A |
Nov. 24, 2019, 8:08 a.m. |
OK |
PyPy 3 |
TESTS |
21 |
186 |
6246400 |
|
1100 |
65627005 |
EzikBro |
A |
Nov. 24, 2019, 8:11 a.m. |
OK |
PyPy 3 |
TESTS |
21 |
327 |
6348800 |
|
1100 |
66476792 |
ydam456 |
A |
Dec. 7, 2019, 9:24 p.m. |
OK |
PyPy 3 |
TESTS |
21 |
327 |
9830400 |
|
1100 |
66475500 |
jory20 |
A |
Dec. 7, 2019, 8:31 p.m. |
OK |
PyPy 3 |
TESTS |
21 |
327 |
9830400 |
|
1100 |
65643276 |
DanilM |
A |
Nov. 24, 2019, 9:08 a.m. |
OK |
PyPy 3 |
TESTS |
21 |
343 |
7270400 |
|
1100 |
65715896 |
ng24_7 |
A |
Nov. 25, 2019, 4:33 p.m. |
OK |
PyPy 3 |
TESTS |
21 |
436 |
12492800 |
|
1100 |
65628856 |
sdhd |
A |
Nov. 24, 2019, 8:17 a.m. |
OK |
PyPy 3 |
TESTS |
21 |
733 |
11571200 |
|
1100 |
65705468 |
Driver12 |
A |
Nov. 25, 2019, 12:24 p.m. |
OK |
PyPy 3 |
TESTS |
21 |
889 |
9523200 |
|
1100 |
66621082 |
yanpekkinen |
A |
Dec. 11, 2019, 6:58 a.m. |
OK |
PyPy 3 |
TESTS |
21 |
904 |
9523200 |
|
1100 |
65685597 |
Lisiy_Lexa |
A |
Nov. 24, 2019, 10:53 p.m. |
OK |
PyPy 3 |
TESTS |
21 |
904 |
9523200 |
|
1100 |
65713470 |
Neumann |
A |
Nov. 25, 2019, 3:24 p.m. |
OK |
Python 2 |
TESTS |
21 |
436 |
5427200 |
|
1100 |
65633548 |
yurver |
A |
Nov. 24, 2019, 8:31 a.m. |
OK |
Python 3 |
TESTS |
21 |
296 |
307200 |
|
1100 |
65638602 |
ooowlyash |
A |
Nov. 24, 2019, 8:49 a.m. |
OK |
Python 3 |
TESTS |
21 |
311 |
0 |
|
1100 |
65650667 |
Kol2ja |
A |
Nov. 24, 2019, 9:46 a.m. |
OK |
Python 3 |
TESTS |
21 |
311 |
307200 |
|
1100 |
65627745 |
Cren |
A |
Nov. 24, 2019, 8:13 a.m. |
OK |
Python 3 |
TESTS |
21 |
311 |
307200 |
|
1100 |
65649249 |
MaxonSMB |
A |
Nov. 24, 2019, 9:39 a.m. |
OK |
Python 3 |
TESTS |
21 |
311 |
5734400 |
|
1100 |
65635779 |
AlxShark |
A |
Nov. 24, 2019, 8:38 a.m. |
OK |
Python 3 |
TESTS |
21 |
312 |
307200 |
|
1100 |
65629723 |
Leonid_Vysotskiy |
A |
Nov. 24, 2019, 8:19 a.m. |
OK |
Python 3 |
TESTS |
21 |
312 |
307200 |
|
1100 |
65634378 |
Maveric_k |
A |
Nov. 24, 2019, 8:34 a.m. |
OK |
Python 3 |
TESTS |
21 |
326 |
0 |
|
1100 |
65626315 |
Cat8ra |
A |
Nov. 24, 2019, 8:08 a.m. |
OK |
Python 3 |
TESTS |
21 |
326 |
307200 |
|
1100 |
66031545 |
maksim_krivoshey |
A |
Nov. 30, 2019, 10:19 a.m. |
OK |
Python 3 |
TESTS |
21 |
327 |
307200 |
|
1100 |
remove filters
Back to search problems