Kotlin Heroes: Episode 6

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
1488 Kotlin Heroes: Episode 6 FINISHED False 9000 121879463 March 9, 2021, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 432 ) C Two Policemen PROGRAMMING *special binary search brute force math

B'There is a street that can be represented as an array of length n . There are two policemen patrolling a street: the first one is standing at the point x of the street and the second one is standing at the point y of the street. During one minute, both policemen can decide what to do (independently): move left (if the current position is greater than 1 ), move right (if the current position is less than n ), or do nothing. The street is considered clear if each point of the street is visited by at least one policeman. Your task is to find the minimum number of minutes the policemen need to visit each point of the street (again, each point should be visited by at least one of them). You have to answer t independent test cases. The first line of the input contains one integer t ( 1 <= t <= 2 cdot 10^4 ) -- the number of test cases. Then t test cases follow. The only line of the test case contains three integers n , x and y ( 2 <= n <= 10^6 ; 1 <= x, y <= n ; x ne y ) -- the length of the street, the position of the first policeman and the position of the second policeman, respectively. It is guaranteed that the sum of n does not exceed 10^6 ( sum n <= 10^6 ). For each test case, print one integer -- the minimum number of minutes the policemen need to visit each point of the street. '...

Tutorials

88522

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
109504270 shojin_pro C March 9, 2021, 4:39 p.m. OK Kotlin TESTS 10 109 0
109500868 Jetman C March 9, 2021, 3:58 p.m. OK Kotlin TESTS 10 109 0
109497249 ir_1st_vil C March 9, 2021, 3:20 p.m. OK Kotlin TESTS 10 109 0
109495458 Thallium54 C March 9, 2021, 3:01 p.m. OK Kotlin TESTS 10 109 0
109493954 eatmore C March 9, 2021, 2:48 p.m. OK Kotlin TESTS 10 109 0
109501352 bohuss C March 9, 2021, 4:04 p.m. OK Kotlin TESTS 10 124 0
109497700 songsinger C March 9, 2021, 3:24 p.m. OK Kotlin TESTS 10 124 0
109497454 okwedook C March 9, 2021, 3:22 p.m. OK Kotlin TESTS 10 124 0
109496767 bobib C March 9, 2021, 3:15 p.m. OK Kotlin TESTS 10 124 0
109496412 user32 C March 9, 2021, 3:11 p.m. OK Kotlin TESTS 10 124 0

remove filters

Back to search problems