Kotlin Heroes: Episode 4

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.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
1346 Kotlin Heroes: Episode 4 FINISHED False 9000 146589911 May 29, 2020, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 137 ) G Two IP Cameras PROGRAMMING *special math number theory 2300

B"You have two IP cameras of the same model. Each camera can take photos starting from some moment of time with a fixed period. You can freely choose the starting moment but you can choose the period only as one of k values p_1, p_2, ... , p_k which are chosen by the camera's manufacturer. You have n moments of interest x_1, x_2, ... , x_n . You'd like to configure both cameras in such a way that at least one camera will take a photo in each of these moments. Configuring the camera means setting the moment when it takes the first photo and the gap between two consecutive photos (which should be one of the values p_1, p_2, ... , p_k ). It's not a problem for you that cameras can take photos at other moments of time -- you only care about moments of interest. The first line contains two integers k and n ( 1 <= k <= 10^5 ; 2 <= n <= 10^5 ) -- the number of periods to choose and the number of moments of interest. The second line contains k integers p_1, p_2, ... , p_k ( 1 <= p_1 < p_2 < ... < p_k <= 10^6 ) -- the periods to choose in the ascending order. The third line contains n integers x_1, x_2, ... , x_n ( 1 <= x_1 < x_2 < ... < x_n <= 10^6 ) -- the moments of interest in the ascending order. Print YES (case insensitive) in the first line if there is a way to configure cameras. In the second line, print two integers s_1 and cp_1 ( 1 <= s_1 <= 10^6 ; 1 <= cp_1 <= 10^6 ; cp_1 in {p_1, ... , p_k } ) -- the starting moment and the period for the first camera. The period should be one of the given periods. In the third line, print two integers s_2 and cp_2 ( 1 <= s_2 <= 10^6 ; 1 <= cp_2 <= 10^6 ; cp_2 in {p_1, ... , p_k } ) -- the starting moment and the period for the second camera. The period should be one of the given periods. If there is no way to configure cameras, print NO (case insen"...

Tutorials

Kotlin Heroes: Episode 4 — Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
81904393 Egor G May 29, 2020, 3:41 p.m. OK Kotlin TESTS 35 187 5017600 2300
81923516 romanandreev G May 29, 2020, 7:30 p.m. OK Kotlin TESTS 35 218 6553600 2300
81910471 sokian G May 29, 2020, 4:33 p.m. OK Kotlin TESTS 35 264 6963200 2300
81923316 romanandreev G May 29, 2020, 7:26 p.m. OK Kotlin TESTS 35 265 6553600 2300
81907857 pashka G May 29, 2020, 4:10 p.m. OK Kotlin TESTS 35 296 30208000 2300
81918132 Fortin G May 29, 2020, 6:04 p.m. OK Kotlin TESTS 35 311 8601600 2300
81916387 eriksuenderhauf G May 29, 2020, 5:37 p.m. OK Kotlin TESTS 35 326 22425600 2300
81911165 magula G May 29, 2020, 4:40 p.m. OK Kotlin TESTS 35 327 4505600 2300
81913157 arccosh G May 29, 2020, 5 p.m. OK Kotlin TESTS 35 358 5427200 2300
81912361 pitfall G May 29, 2020, 4:52 p.m. OK Kotlin TESTS 35 358 14643200 2300

remove filters

Back to search problems