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"You are given n intervals in form [l; r] on a number line. You are also given m queries in form [x; y] . What is the minimal number of intervals you have to take so that every point (not necessarily integer) from x to y is covered by at least one of them? If you can't choose intervals so that every point from x to y is covered, then print -1 for that query. The first line contains two integers n and m ( 1 <= n, m <= 2 cdot 10^5 ) -- the number of intervals and the number of queries, respectively. Each of the next n lines contains two integer numbers l_i and r_i ( 0 <= l_i < r_i <= 5 cdot 10^5 ) -- the given intervals. Each of the next m lines contains two integer numbers x_i and y_i ( 0 <= x_i < y_i <= 5 cdot 10^5 ) -- the queries. Print m integer numbers. The i -th number should be the answer to the i -th query: either the minimal number of intervals you have to take so that every point (not necessarily integer) from x_i to y_i is covered by at least one of them or -1 if you can't choose intervals so that every point from x_i to y_i is covered. In the first example there are three queries: In the second example there are four queries: "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
55539188 |
rainboy |
E |
June 13, 2019, 6:28 p.m. |
OK |
GNU C11 |
TESTS |
56 |
1044 |
38092800 |
|
2200 |
55210902 |
llbra9z |
E |
June 6, 2019, 2:35 p.m. |
OK |
GNU C11 |
TESTS |
56 |
1107 |
44134400 |
|
2200 |
55210919 |
llbra9z |
E |
June 6, 2019, 2:35 p.m. |
OK |
GNU C11 |
TESTS |
56 |
1107 |
44134400 |
|
2200 |
55210951 |
llbra9z |
E |
June 6, 2019, 2:36 p.m. |
OK |
GNU C11 |
TESTS |
56 |
1201 |
44134400 |
|
2200 |
62624983 |
chasedeath |
E |
Oct. 15, 2019, 1:49 p.m. |
OK |
GNU C++11 |
TESTS |
56 |
139 |
26419200 |
|
2200 |
57878631 |
vjudge3 |
E |
July 28, 2019, 6:44 a.m. |
OK |
GNU C++11 |
TESTS |
56 |
140 |
24473600 |
|
2200 |
57782237 |
vjudge1 |
E |
July 26, 2019, 6:25 a.m. |
OK |
GNU C++11 |
TESTS |
56 |
140 |
26419200 |
|
2200 |
57878756 |
vjudge2 |
E |
July 28, 2019, 6:47 a.m. |
OK |
GNU C++11 |
TESTS |
56 |
155 |
24371200 |
|
2200 |
62625118 |
chasedeath |
E |
Oct. 15, 2019, 1:51 p.m. |
OK |
GNU C++11 |
TESTS |
56 |
155 |
26419200 |
|
2200 |
56181314 |
smalov |
E |
June 27, 2019, 11:56 p.m. |
OK |
GNU C++11 |
TESTS |
56 |
217 |
19968000 |
|
2200 |
62854289 |
NihilistPilgrim |
E |
Oct. 18, 2019, 8:39 a.m. |
OK |
GNU C++11 |
TESTS |
56 |
218 |
15155200 |
|
2200 |
57878505 |
1849285087 |
E |
July 28, 2019, 6:40 a.m. |
OK |
GNU C++11 |
TESTS |
56 |
218 |
19968000 |
|
2200 |
57878463 |
vjudge2 |
E |
July 28, 2019, 6:39 a.m. |
OK |
GNU C++11 |
TESTS |
56 |
218 |
19968000 |
|
2200 |
61349887 |
NihilistPilgrim |
E |
Sept. 27, 2019, 7:28 a.m. |
OK |
GNU C++11 |
TESTS |
56 |
234 |
17203200 |
|
2200 |
58262154 |
vjudge2 |
E |
Aug. 4, 2019, 12:47 p.m. |
OK |
GNU C++14 |
TESTS |
56 |
264 |
18432000 |
|
2200 |
55282241 |
Holland_Pig |
E |
June 8, 2019, 2:10 a.m. |
OK |
GNU C++14 |
TESTS |
56 |
264 |
23244800 |
|
2200 |
56735523 |
YJU |
E |
July 9, 2019, 4:56 a.m. |
OK |
GNU C++14 |
TESTS |
56 |
311 |
23244800 |
|
2200 |
55431926 |
F0_0H |
E |
June 11, 2019, 11:52 a.m. |
OK |
GNU C++14 |
TESTS |
56 |
311 |
59494400 |
|
2200 |
55555275 |
Kostya_Smirnov |
E |
June 14, 2019, 9:33 a.m. |
OK |
GNU C++14 |
TESTS |
56 |
312 |
30515200 |
|
2200 |
55379521 |
vishusachdeva |
E |
June 9, 2019, 7:28 p.m. |
OK |
GNU C++14 |
TESTS |
56 |
327 |
36864000 |
|
2200 |
55664631 |
eidan |
E |
June 17, 2019, 2:14 a.m. |
OK |
GNU C++14 |
TESTS |
56 |
327 |
39014400 |
|
2200 |
57783840 |
vjudge3 |
E |
July 26, 2019, 7 a.m. |
OK |
GNU C++14 |
TESTS |
56 |
358 |
24883200 |
|
2200 |
55228613 |
rdd6584 |
E |
June 7, 2019, 3:53 a.m. |
OK |
GNU C++14 |
TESTS |
56 |
373 |
19251200 |
|
2200 |
57782471 |
vjudge5 |
E |
July 26, 2019, 6:30 a.m. |
OK |
GNU C++14 |
TESTS |
56 |
374 |
24780800 |
|
2200 |
55426376 |
Trote_w |
E |
June 11, 2019, 9:11 a.m. |
OK |
GNU C++17 |
TESTS |
56 |
233 |
39219200 |
|
2200 |
55610544 |
ReaLNero1 |
E |
June 16, 2019, 5:24 a.m. |
OK |
GNU C++17 |
TESTS |
56 |
234 |
23244800 |
|
2200 |
55528819 |
muzzle |
E |
June 13, 2019, 12:30 p.m. |
OK |
GNU C++17 |
TESTS |
56 |
234 |
23244800 |
|
2200 |
55605434 |
anybody... |
E |
June 15, 2019, 10:24 p.m. |
OK |
GNU C++17 |
TESTS |
56 |
249 |
23244800 |
|
2200 |
55300191 |
Holland_Pig |
E |
June 8, 2019, 11:42 a.m. |
OK |
GNU C++17 |
TESTS |
56 |
265 |
23244800 |
|
2200 |
55300265 |
Holland_Pig |
E |
June 8, 2019, 11:44 a.m. |
OK |
GNU C++17 |
TESTS |
56 |
265 |
23244800 |
|
2200 |
55463471 |
stefanbalaz2 |
E |
June 11, 2019, 3:52 p.m. |
OK |
GNU C++17 |
TESTS |
56 |
280 |
28364800 |
|
2200 |
65925665 |
mikuz |
E |
Nov. 28, 2019, 6:10 p.m. |
OK |
GNU C++17 |
TESTS |
56 |
295 |
16384000 |
|
2200 |
55305558 |
ayk16 |
E |
June 8, 2019, 2:13 p.m. |
OK |
GNU C++17 |
TESTS |
56 |
358 |
27238400 |
|
2200 |
55283096 |
maxtir |
E |
June 8, 2019, 2:54 a.m. |
OK |
GNU C++17 |
TESTS |
56 |
373 |
24473600 |
|
2200 |
68970664 |
zhanyi_xiaolu |
E |
Jan. 17, 2020, 6:51 a.m. |
OK |
Java 11 |
TESTS |
56 |
1014 |
124723200 |
|
2200 |
55223944 |
ashen.lily |
E |
June 6, 2019, 10:28 p.m. |
OK |
Java 8 |
TESTS |
56 |
390 |
58470400 |
|
2200 |
55228422 |
bluesky111 |
E |
June 7, 2019, 3:44 a.m. |
OK |
Java 8 |
TESTS |
56 |
467 |
58470400 |
|
2200 |
59374304 |
beginner1010 |
E |
Aug. 23, 2019, 8:43 p.m. |
OK |
Java 8 |
TESTS |
56 |
483 |
58470400 |
|
2200 |
59374269 |
beginner1010 |
E |
Aug. 23, 2019, 8:42 p.m. |
OK |
Java 8 |
TESTS |
56 |
530 |
126771200 |
|
2200 |
59374219 |
beginner1010 |
E |
Aug. 23, 2019, 8:40 p.m. |
OK |
Java 8 |
TESTS |
56 |
545 |
126771200 |
|
2200 |
58401348 |
ISSAM_LAKOUAM |
E |
Aug. 6, 2019, 5:57 p.m. |
OK |
Java 8 |
TESTS |
56 |
592 |
58675200 |
|
2200 |
55202002 |
Ahmed_Diab |
E |
June 6, 2019, 10:59 a.m. |
OK |
Java 8 |
TESTS |
56 |
592 |
58777600 |
|
2200 |
55179111 |
Ahmed_Diab |
E |
June 5, 2019, 8:22 p.m. |
OK |
Java 8 |
TESTS |
56 |
592 |
58777600 |
|
2200 |
55201954 |
Ahmed_Diab |
E |
June 6, 2019, 10:58 a.m. |
OK |
Java 8 |
TESTS |
56 |
608 |
61849600 |
|
2200 |
55175720 |
cplayer |
E |
June 5, 2019, 6:35 p.m. |
OK |
Java 8 |
TESTS |
56 |
638 |
76800000 |
|
2200 |
55308070 |
camypaper |
E |
June 8, 2019, 3:46 p.m. |
OK |
Mono C# |
TESTS |
56 |
1138 |
91648000 |
|
2200 |
55424577 |
eki |
E |
June 11, 2019, 8:16 a.m. |
OK |
Mono C# |
TESTS |
56 |
1949 |
58982400 |
|
2200 |
55294491 |
tarattata1 |
E |
June 8, 2019, 9:15 a.m. |
OK |
MS C++ |
TESTS |
56 |
374 |
41676800 |
|
2200 |
57261049 |
vjudge2 |
E |
July 18, 2019, 5:10 a.m. |
OK |
MS C++ |
TESTS |
56 |
405 |
40038400 |
|
2200 |
55425831 |
vjudge1 |
E |
June 11, 2019, 8:55 a.m. |
OK |
MS C++ |
TESTS |
56 |
421 |
44134400 |
|
2200 |
56376293 |
vjudge1 |
E |
July 1, 2019, 6:41 a.m. |
OK |
MS C++ |
TESTS |
56 |
436 |
92160000 |
|
2200 |
57782220 |
vjudge3 |
E |
July 26, 2019, 6:25 a.m. |
OK |
MS C++ |
TESTS |
56 |
468 |
58163200 |
|
2200 |
57313240 |
vjudge5 |
E |
July 19, 2019, 7:17 a.m. |
OK |
MS C++ |
TESTS |
56 |
483 |
52121600 |
|
2200 |
63773857 |
vjudge2 |
E |
Oct. 30, 2019, 8:52 a.m. |
OK |
MS C++ |
TESTS |
56 |
498 |
80179200 |
|
2200 |
56368924 |
vjudge2 |
E |
July 1, 2019, 2:03 a.m. |
OK |
MS C++ |
TESTS |
56 |
498 |
92160000 |
|
2200 |
68851733 |
vjudge5 |
E |
Jan. 15, 2020, 9:11 a.m. |
OK |
MS C++ |
TESTS |
56 |
498 |
120217600 |
|
2200 |
57080949 |
vjudge3 |
E |
July 15, 2019, 7:12 a.m. |
OK |
MS C++ |
TESTS |
56 |
499 |
54067200 |
|
2200 |
56026127 |
xsc |
E |
June 25, 2019, 6:59 a.m. |
OK |
MS C++ 2017 |
TESTS |
56 |
467 |
45260800 |
|
2200 |
55493213 |
tiantian5 |
E |
June 12, 2019, 11:11 a.m. |
OK |
MS C++ 2017 |
TESTS |
56 |
920 |
45056000 |
|
2200 |
55202460 |
TrickmanOff |
E |
June 6, 2019, 11:10 a.m. |
OK |
MS C++ 2017 |
TESTS |
56 |
982 |
42188800 |
|
2200 |
55173873 |
FatXi |
E |
June 5, 2019, 5:50 p.m. |
OK |
MS C++ 2017 |
TESTS |
56 |
1855 |
51814400 |
|
2200 |
55731609 |
yumtam |
E |
June 18, 2019, 9:55 p.m. |
OK |
PyPy 2 |
TESTS |
56 |
1855 |
87449600 |
|
2200 |
55200474 |
meooow |
E |
June 6, 2019, 10:22 a.m. |
OK |
PyPy 3 |
TESTS |
56 |
763 |
83251200 |
|
2200 |
55200147 |
meooow |
E |
June 6, 2019, 10:14 a.m. |
OK |
PyPy 3 |
TESTS |
56 |
873 |
69939200 |
|
2200 |
55308391 |
Kiri8128 |
E |
June 8, 2019, 3:58 p.m. |
OK |
PyPy 3 |
TESTS |
56 |
1294 |
73728000 |
|
2200 |
55308236 |
Kiri8128 |
E |
June 8, 2019, 3:52 p.m. |
OK |
PyPy 3 |
TESTS |
56 |
1326 |
75366400 |
|
2200 |
65325176 |
sansen |
E |
Nov. 19, 2019, 12:01 a.m. |
OK |
Rust |
TESTS |
56 |
296 |
29798400 |
|
2200 |
55267956 |
kobae964 |
E |
June 7, 2019, 3:06 p.m. |
OK |
Rust |
TESTS |
56 |
607 |
41676800 |
|
2200 |
67631490 |
gearjack |
E |
Dec. 26, 2019, 4:19 a.m. |
OK |
Rust |
TESTS |
56 |
717 |
54374400 |
|
2200 |
remove filters
Back to search problems