### kostka's blog

By kostka, 7 months ago, ,

It's almost here! KickStart rounds kick off this Sunday, March 24 with Round A at 4:00UTC. Get ready and register now at g.co/kickstart.

.

• +8

 » 7 months ago, # |   +1 The URL is appended after codeforces/blog/entry, please fix that : )
•  » » 7 months ago, # ^ |   0 Ups, sorry, already fixed!
 » 7 months ago, # |   0 What would be the difficulty of the round ?
•  » » 7 months ago, # ^ | ← Rev. 2 →   0 It's hard to estimate... You can check previous rounds to have some grasp on the difficulty. I'd say it's easier than the Code Jam, but this is my personal opinion.
•  » » » 7 months ago, # ^ | ← Rev. 2 →   +4 yes , , but you said easier than code jam .which round you are considering , QR , R1 , R2 or ,WF ?
 » 7 months ago, # | ← Rev. 3 →   +30 I can't see/view the problems/scoreboard :(EDIT: Now it works
•  » » 7 months ago, # ^ |   +30 its still not working.scoreboard is loading....
•  » » 7 months ago, # ^ |   0 I see 2 people on the scoreboard, but where are the problems??
•  » » 7 months ago, # ^ |   +5 codejam 2018: Guys we don't think it's a good idea to use the new UI kick-start 2019: GUESS WHAT
•  » » » 7 months ago, # ^ |   0 It's okay, even Googlers are humans. But they should still ensure such things don't repeat in the future rounds.But yeah, we got something after Codechef to criticize xD
•  » » » » 7 months ago, # ^ |   0 Yeah, I tried to hold my rants.... My temper have limits and I figured out that I should let some of it out after waiting for almost a year since last year's codejam.
 » 7 months ago, # |   0 It shows for me, 6 minutes before round starts, and I can also see the problems. What is happening??
•  » » 7 months ago, # ^ |   +1 Google contests have the shittiest UI. This happened in hashcode as well. Now I see 90% people have already submitted A.How long ago did the contest start? I took a screenshot.
•  » » » 7 months ago, # ^ |   +5 likely some timezone issue in their system xdthe contest started an hour ago
 » 7 months ago, # | ← Rev. 4 →   +26 Codeforces finally works... Didn't even have a place to complain about the competition...Failed to submit C small... should've get a better rank. We even cannot say, "Hey, please make this unrated." like what we usually do when such things happen in Codeforces.
•  » » 7 months ago, # ^ |   +9 I was about to post the same comment here about 15min before the round was to end.But even CF was down. Lol you won the race :P
 » 7 months ago, # | ← Rev. 2 →   0 Oh boy, I can't wait to see all the rants when codejam also transits into this UI and judging system. Good luck on dealing with all the lagging issues.
 » 7 months ago, # |   +16 What was your approach on problem C?
•  » » 7 months ago, # ^ | ← Rev. 2 →   +1 Observation: If A >= B (A fully contains B), there must exists some OPT ordering where B is ordered before A. (If A is committed before B then B will get 0 seats so obvoiusly no) If two order does not share a seat then their relative order does not matter. Construct a DAG from the >= relationship. We shall try to place "smaller" orders before larger ones, in a toposort fashion. Pick any order that does not contain a unprocessed order(segment), Pick all other orders which do not have an unprocessed >= relationship in the toposort and overlaps with the current order (recursively), call this a group. We binary search for k on each group (and take min of all afterwards), use two pointer to check if all order got at least "mid" seats (two pointer from i-th order in the group to j-th order in the group, the starting point of the i-th order is only affected by the ending point of the (i-1)-th order), while using some range query data structure to query the amount of unprocessed seats in the range.Time complexity: O(n lg^2 n)
•  » » » 7 months ago, # ^ |   +13 I am sorry but I cannot understand this. Did you try submitting it?If so, can you share the code?
•  » » » » 7 months ago, # ^ |   0 I submitted it after the editorial is released but it doesn't work, also fails in Errichto's test case :/
•  » » 7 months ago, # ^ |   0 First binary search the answer. Let the current answer be $k$.Consider the intervals in the reverse order (i.e. from the last interval in the schedule.). For example there are three intervals $[1,5], [2,4], [3,6]$, and $k = 2$ now. We know that $[1,5]$ cannot be the last interval since we know that if so, $[2,4]$ and $[3,6]$ already covers some range and $[1,5]$ can only have seat $1$. $[2,4]$ cannot be the last interval for the same reason, but $[3,6]$ can be the last interval. As long as there are intervals that can be put in the last position, we put them and the problem becomes a smaller one. If there are none, then the current $k$ is not possible, and we switch to smaller value.Different implementations of this can lead to different complexity. It will be easy to get the small with the idea above, but I am still thinking about how to use data structure to solve large.
•  » » » 7 months ago, # ^ | ← Rev. 4 →   +6 Just to add. I had similar idea for solving small. Instead of binary search always take the max length segment as the last segment.
•  » » » » 7 months ago, # ^ |   0 Do you think flows will work? Source to each seat has capacity 1. Seats to bookings are edges of capacity 1. We can compress the seat ranges, and change capacity from source to seats but maybe not needed. Then you add edges from bookings to sink with capacity k. And finally you find maxflow here, and check that all incoming edges have flow = k. Then you binary search on k.
•  » » » » » 7 months ago, # ^ |   +5 No, because we are given each person takes all the seats available and not the amount he just needs
•  » » » » » » 7 months ago, # ^ |   0 Ok I misunderstood the statement then.
•  » » » » 7 months ago, # ^ |   0 Nice observation! Sounds like a way to help us solve large.
•  » » » » » 7 months ago, # ^ |   +22 I think we can also say that there will atmost sqrt(n) distinct values possible for the max segment at each stage throughout but I still do not know how to use this and solve the problem fast.
•  » » » » 7 months ago, # ^ |   0 Will it not fail for test cases like: 1 20  3 1  10 11  20 4  17
•  » » 7 months ago, # ^ |   +5 From problem C editorial:"Another observation is that at every step we can always choose this request greedily from the remaining set: the one where we can book the maximum number of seats."Shouldn't we pick the request which yields the min number of seats as it will only drops when we allocate more and more seats?
•  » » » 7 months ago, # ^ |   +21 I thought so and found a countertest: N=8 Q=3 2 8 1 4 5 8 
•  » » » » 7 months ago, # ^ |   0 Great test case, max(min) always get me screwed...Then picking max backwards do makes sense, picking max(min) in each iteration whlie allowing other requests to grow does construct an impeccable greedy solution.
 » 7 months ago, # |   +16 how to solve B ?
•  » » 7 months ago, # ^ |   0 I'm really not sure about my idea, bcz I didn't really do this round seriously, but maybe like this : First find the best values for each cell with parallel bfs from all available centers. Then binary search on the answer and find the point which you can make as a center for the new building for each value > bin_search_value.
•  » » » 7 months ago, # ^ |   0 okay bs the answer,now how can we find out the position of the cell in n*m for each mid in bs? bcz mine n*n*m gives tle
•  » » » » 7 months ago, # ^ | ← Rev. 2 →   0 So, this is the part I didn't think about, because I was so done with kickstart by that time.But n^3 * T for 15sec should not TLE, right?
•  » » » » » 7 months ago, # ^ | ← Rev. 2 →   0 i also think it will pass, but sad, it did not passed in my case..u tried n^3?
•  » » » » » » 7 months ago, # ^ |   0 well n*n*m == n^3 in terms of complexity :|
•  » » » » » » » 7 months ago, # ^ |   0 yep
•  » » » » » » » » 7 months ago, # ^ |   0 Actually, mine isn't Tn^3, it's Tn^2logn.You do 2D partial sums per binary search, and if there's a cell having a number equal to all cells you must reach from the new building, to get that bin_search_value as your answer, you know what to do from there.The problem is that, partial sums is not on a proper rectangle. It's on a tilted rectangle. I faced a similar problem once. https://www.hackerrank.com/contests/hourrank-27/challenges/moving-the-kingsBut I didn't do anything after submitting A, and reading B and C during contest. But now that I thought about the problem, I think I don't like problems that require specific knowledge than using a nice observation. I didn't like that hackerrank problem as well, but oh well((
•  » » » » 7 months ago, # ^ | ← Rev. 2 →   0 How to solve in O(n ^ 3) , I could not think better than O(n ^ 4). Can you explain your solution a bit ?
•  » » » » » 7 months ago, # ^ | ← Rev. 2 →   0 .
•  » » » » » » 7 months ago, # ^ | ← Rev. 2 →   0 Will there be always n + m maximum these "X" maximum cells as a input matrix something like this would give precisely (n * m) / 2 cells which are maximum . 1 0 1 0 1 0 ... 1 0 0 1 0 1 0 1 ... 0 1 1 0 1 0 1 0 ... 1 0 0 1 0 1 0 1 ... 0 1 1 0 1 0 1 0 ... 1 0 0 1 0 1 0 1 ... 0 1 1 0 1 0 1 0 ... 1 0 0 1 0 1 0 1 ... 0 1 So wouldn't it result in O(n ^ 4) solution ?
•  » » » » » » » 7 months ago, # ^ |   +1 good point at that time i think about 100000 100000 100000 ...... 100000
 » 7 months ago, # | ← Rev. 2 →   0 In question B, if we take all zeroes except 1 at one corner, one of the accepted solutions will have a complexity of 10^9 and another code 4*10^8 for this test case. How does 100 test cases with similar test data doesn't give his/her code a TLE?
 » 7 months ago, # |   0 Hints for B and C?
•  » » 7 months ago, # ^ |   +1 When Code Jam is right around the corner, and there are more Kickstart rounds coming months, losing sleep in order to participate in this round sounded like a super bad idea for me.
•  » » » 7 months ago, # ^ |   +3 Yes, indeed. It was all my fault.
 » 7 months ago, # |   +4 Editorials were published and are available in the problem view.
•  » » 7 months ago, # ^ |   +30 Please don't make us play treasure hunt on your website, please give the link.
•  » » » 7 months ago, # ^ |   0 See if this link works for you.
•  » » » » 7 months ago, # ^ |   +4 Beautiful! It's on the codejam website. Did they forget it's kickstart?
•  » » » » » 7 months ago, # ^ |   0 I guess it'd be on the kickstart site as well but I wasn't able to find it :/
•  » » » » » » 7 months ago, # ^ |   0 Me neither.
•  » » » » » » 7 months ago, # ^ |   0 It's next to each of the problem.
•  » » » » » » » 7 months ago, # ^ |   0 Oh, maybe they added it now. It wasn't there 5 minutes ago. I checked.
•  » » » » 7 months ago, # ^ |   0 Wow, nice link. I thought we must enter a problem and then hit "analysis" hidden in the middle (really, it's there).In your link, the scoreboard is broken in an unusual way. Looks like problems A and C have a subtask worth 0 points and because of that nobody solved the last subtask.
•  » » 7 months ago, # ^ |   +19 In C, does the editorial simulate the process from the end?"Another observation is that at every step we can always choose this request greedily from the remaining set: the one where we can book the maximum number of seats. ... At every step we intend to find the request where we can book the maximum seats, remove this request from the set and recalculate the number of seats we can book for the remaining requests. "During the contest, I implemented a solution where we greedily take an interval with the smallest number of available seats. Got WA and then found a countertest :(
•  » » » 7 months ago, # ^ |   0 I am thinking about to choose smallest segment and delete that from set and go ahead, is there any counter test case for this?
•  » » » » 7 months ago, # ^ |   0 Yes, I pasted it a few comments above. Intervals $[2, 8], [1, 4], [5, 8]$.
•  » » » » » 7 months ago, # ^ |   0 correct output and what is the order?
•  » » » » » » 7 months ago, # ^ |   0 [5, 8], [2, 8], [1, 4], k = 1.
•  » » » » » » 7 months ago, # ^ |   +21 Come on, you could check brute force it yourself in seconds. You must take the last interval first. The answer is $1$.
•  » » » » » » » 7 months ago, # ^ |   0 got it,thanks
•  » » » » » » » 7 months ago, # ^ |   0 Why in this case the answer is 1? in first segment 4,5 in second segment 7,8 in third segment 1,2 Could you explain what I'm missing?
•  » » » » » » » » 7 months ago, # ^ |   0 I think you misunderstood the statement. A query takes all the available seats in the interval.
•  » » » 7 months ago, # ^ | ← Rev. 2 →   0 Yes we simulate from the end, the previous line states "We can observe that for a chosen ordering of the requests, the number of seats that we can book in the last request does not depend on the ordering of the previous Q — 1 requests."
•  » » » 7 months ago, # ^ |   0 Any proof for the observation stated above?
•  » » 7 months ago, # ^ |   +1 the submit button is not worked in last hour, I cant make submission for B and C then, what will be the solution of that? there is also a public announcement regarding this
•  » » » 7 months ago, # ^ |   +3 I'd imagine they will end up inviting more contestants than usual and tell everyone better luck next time.
•  » » » » 7 months ago, # ^ |   0 sad for me in very beginning of the day
 » 7 months ago, # |   0 Can someone please tell why I am getting Run-Time error for training Problem, My code : "https://ideone.com/e.js/oRGkWq
•  » » 7 months ago, # ^ |   0 Even I want to know. What is the procedure of submitting there. Not close to codeforces way of submitting.Found this: https://code.google.com/codejam/resources/quickstart-guide but still unclear
•  » » » 7 months ago, # ^ |   +1 Hi Abhinav, If you are using Java, You need to have your class name Solution. I wasted am an hour because of this. I should have read that guide earlier.
 » 7 months ago, # |   0 Why does my B WA?I've done what the editorial said, it passes samples but fails the main testshttps://ideone.com/iDlNtNI think there might be something wrong with my check function if I misunderstood the editorialIn my check function, I take maximum and minimum over all x+y and x-y for all points where their current distance from a post office is >kThen I individually check each of these 4 values to see whether it can lie within the square with centre (i,j)to do this, each of the precomputed values — (i+-j) must be less than or equal to kShouldn't this work?
•  » » 7 months ago, # ^ |   0 Line 43, not necessary you are going to put a delivery office if the distance is greater than K , besides that there is another bug that neither I don't know yet.
•  » » 7 months ago, # ^ | ← Rev. 2 →   0 010000if you skip distance 1 cooridinate, you get answer 2. but it's 1 selecting the (2,2) point
•  » » » 7 months ago, # ^ |   0 1 2 3 010 000gives 1?https://ideone.com/cR0pXA
•  » » » » 7 months ago, # ^ |   0 yes. your previous code gives wrong answer.
•  » » » » » 7 months ago, # ^ |   0 oh right I changed it because of the other commentbut this still WAs
•  » » » 7 months ago, # ^ |   0 hello, this is my solutionB for b's small test, i pass the above test, but i get wrong answer during the contest, what the bug in my solution or i misunderstand the problem statements?
 » 7 months ago, # | ← Rev. 2 →   +4 Can someone please explain that in second question in binary search function, how do we find optimal cell which can give maximum distance atmost K in O(RC). I could not figure it out from editorial. They said it is.dist((x1, y1), (x2, y2)) = max(abs(x1 + y1 — (x2 + y2)), abs(x1 — y1 — (x2 — y2))) How do we get this?
•  » » 7 months ago, # ^ |   +4 Consider the four corners of a box, the first term is "dist(top right, bottom left)", second term is "dist(bottom right, top left)". With the bottom left corner as (0, 0).
•  » » » 7 months ago, # ^ |   0 Thank you! Got it :)
•  » » » » 6 months ago, # ^ | ← Rev. 2 →   0 can u please explain how u have find optimal cell which can give max distance atmost K in O(RC)?
 » 7 months ago, # | ← Rev. 7 →   +47 Since there are a few people PM-ing for clarification about the problem C editorial I think I might as well create a short summary here: Why does picking the min order in the forward direction doesn't workThe issue here is that you are not doing dynamic planning here. While I can't give a formal argument in disproving if this approach is correct with some special tie-breaking method, I cannot prove it is correct either, due to the fact that min(jth request) is dependent on the subset available for the jth request. While it is guaranteed that the order shall generate less seats if they come later, you might not care about the decrease if K is significantly smaller than it.If this is your first time dealing with min max stuff and you can't see why does such plan causes a bad K in the future, a problem that I would recommend on top of my head is "HDU 6000 Wash".Why does picking max backwards works hereBefore I continue I must clarify the editorial's approach as it is proven to be confusing to multiple readers.Consider the corner test case provided by Errichto. N=8 Q=3 2 8 1 4 5 8 What the editorial meant by picking the max segment is that you must imagine that the other segments have been picked prior to the concerned request, for example, the first iteration would be:[2, 8] : Imagine that [1, 4], [5, 8] has been occupied, and picking [2, 8] last must yield 0 seats.[1, 4]: Imagine that [2, 8], [5, 8] has been occupied, and picking [1, 4] last must secure 1 seat.We shall pick [1, 4] as the last request processed (we skip [5, 8] as an exercise for the reader).On the second iteration, you will prioritize picking [2, 8] as it yields 3 seats. Note that you should imagine [1, 4] as not processed as you are considering [2, 8] as the 2nd request and [1, 4] is chosen to be the 3rd request, which is satisfied after picking [2, 8].Now we may apply a similar argument: If the request was satisfied after processing only a set of request S, it must yield more seats as it would after processing the set (S union T). As an informal proof, consider that the request i was picked on time j is the bottleneck of the ordering, i.e. it secures only k seats, let's see what happens if we attempt to process it in another time.If request i swapped place with the request processed on time jg > j: It will then yield even less seats so the new k must be decreased.If request i ... time jl < j: Note that we picked request i on time j because it yields the most seats at the time. Swapping it with any other picks must yield less than k seats on that iteration, resulting a worse allocation.To generalize the proof above, one must show that k is non-increasing even for arbitrary swap. This is left as an exercise to the reader.
•  » » 7 months ago, # ^ |   +13 In the last line , did you mean non-increasing?
•  » » » 7 months ago, # ^ |   +13 Ah yes, thanks for pointing that out.
•  » » 7 months ago, # ^ | ← Rev. 4 →   0 Thanks. Your answer is crisp and clear. But after reading your answer, I still don't understand following in their editorial: "the number of unique ranges that the requests cover is at max 2 * Q, which would make our solution run in O(Q^2) for every test case." — From where did the factor of 2 come in 2*Q? I don't understand this line. Shouldn't the maximum unique ranges be Q if we are given Q queries?
•  » » » 7 months ago, # ^ |   0 I think "equivalence class" is a better word for "unique range". Whenever you add a new query.For example, if you have [1, 100], [2, 101], and you add [3, 102], two classes will be cut by the new query, namely [2, 100] is cut into [2, 2] and [3, 100], and [101, N] is cut into [101, 101], [102, N].
•  » » » » 7 months ago, # ^ |   0 Ok got it. We have to traverse a max of 2 * Q points.
 » 7 months ago, # |   +27 I don't think I've seen anyone else mention it here, but the new "search bar" is incredibly laggy, and the lack of a friends list adds to the annoyance as it was there in the 2018 UI. I'm sure that a good number of other people feel the same way about these features...
•  » » 7 months ago, # ^ |   0 Other issues majorly affected participants negatively. Compared to them, this one was much smaller and forgiven (
 » 7 months ago, # |   +18 My solution to problem B was O((RC)^2) and it passed the hidden tests. The key was to randomly order the squares with 0 before checking each of them. I didn't do formal math (just convinced myself with some examples) about this but it seems to work. Did somebody do the math?My submission
•  » » 7 months ago, # ^ |   +5 Interesting. It sounds like you are using similar concept behind randomized trick Radewoosh mentioned?
•  » » » 7 months ago, # ^ |   +5 Yes, you are right. Actually, I learned about this concept reading that post and I find it really interesting. I usually think about applying this idea when I don't find a way to improve the asymptotic complexity and I see that the worst case somehow depends on the order you process some data.
 » 7 months ago, # |   0 Would anyone like to point out what I'm doing wrong in my simple solution Problem B's visible tests? I feel like I'm following the analysis properly.https://codeforces.com/contest/1141/submission/51800899
•  » » 7 months ago, # ^ |   0 In this case the answer is 1 and your code gives 2 as result: 1 2 3 010 000 It is because the farthest point is not necessarily the optimal.
•  » » » 7 months ago, # ^ |   0 I see now, thank you for that!
 » 7 months ago, # | ← Rev. 2 →   +16 Could someone help me understand the editorial solution to the large test for C? I don't understand how we can quickly determine which seats are covered by exactly one interval. Is this operation provided by the interval tree, or does this need to be determined in some other way?
•  » » 7 months ago, # ^ |   +5 Do a parallel binary search on a min segment tree.
 » 7 months ago, # |   0 Analysis: The number of possible orderings of the requests is Factorial(Q), which would not be fast enough for either of the test sets. We can observe that for a chosen ordering of the requests, the number of seats that we can book in the last request does not depend on the ordering of the previous Q - 1 requests. Another observation is that at every step we can always choose this request greedily from the remaining set: the one where we can book the maximum number of seats.I think it's not a right greedy approach to chose a request with maximum possible bookings of seats. Consider a case for 2 intervals: [1,4] and [1,2]. According to this approach[1,4] will be chosen first and then no seat for [1,2]. Hence ans=0 but in the opposite way, we can get ans=2. It is possible that I didnt understand what the statement means. If that is the case please let me know.
•  » » 7 months ago, # ^ |   +3 Since we are considering a query to be the last query in remaining set, maximum possible seats means the number of seats requested only by this query, as if a seat is requested also by another query, it would have been already given to that query. So, for 2 intervals[1,4] and [1,2], seats available to [1,4] is 2 and seats available to [1,2] is 0, so we select [1,4] as last query. Now, seats available for [1,2] is 2 and so we select it as 2nd last query/first query. And since both queries has 2 seats, our answer will be 2.
 » 7 months ago, # |   0 I want little consultation here. I solved A problem in 24 minutes and could not think of a solution for B and C. Finally I submitted O(n^4) brute force solution for B which passed smaller test cases.So, to perform well in Kickstart I have to focus mainly on implentation and adhoc type ? And, were coders of DIV1 on codeforces able to solve 2nd and 3rd question correctly ?Can anyone provide an analysis of what type of problem they ask and how to be good at them ?
 » 7 months ago, # |   0 Can anyone explain in detail how the greedy approach in working in problem C.
•  » » 7 months ago, # ^ |   +19 Someone already did. Just read the comments.
 » 7 months ago, # |   +3 Can someone post the Code(preferably Cpp) for second question that uses the binary search as discussed in editorial? I have cannon figure out how to calculate maximum distance from the location to a square in constant time for all locations that have greater than k values.
•  » » 7 months ago, # ^ |   +1 Here is what I did: first calculated distance of each node from the current delivery office using multisource bfs then do a binary search on the answer k. For a valid k, we have all distance less than or equal to k so adding a new position (let it be a,b) as delivery offices only affects the positions x,y within the rhombus: abs(x-a)+abs(y-b) <= k so you only need to verify that does there exist a point in which all > k current distance nodes are all inside the rhombus which can be calculated easily using maximum x+y, maximum x-y, minimum x+y and minimum x-y of all the points with distance > k. CODE : https://ideone.com/uBTBJx
 » 7 months ago, # | ← Rev. 3 →   +3 Please explain this part in the analysis of problem B: "Hence, we can compute the maximum and minimum values of both x1 + y1 and x1 — y1 for all squares with a delivery time greater than K."why do we need to compute max and min of x1+y1 and x1-y1? why do we want the distance of x2,y2 maximized?I am having a hard time understanding the analysis :'(
•  » » 7 months ago, # ^ | ← Rev. 5 →   +4 For two points (r1, c1) and (r2, c2) we have four possible cases. r1 < r2 && c1 < c2. So distance here is D = r2 — r1 + c2 — c1. r2 < r1 && c1 < c2. So distance here is D = r1 — r2 + c2 — c1. r1 < r2 && c2 < c1. So distance here is D = r2 — r1 + c1 — c2. r2 < r1 && c2 < c1. So distance here is D = r1 — r2 + c1 — c2. Now lets fix (1). Its equal to D = (r2 + c2) — (r1 + c1).Also lets fix (4). Its equal to D = (r1 + c1) — (r2 + c2).This means that case (1) and case (4) is equal in absolute value. These cases stand for the first term in the tutorial. With similar method you can take that (2) and (3) stand for the second term in the tutorial.So if we use abs() we don't have four cases but two cases. The team of (1)-(4) and the team of (2)-(3). Also the real distance is the maximum of these. You can convince yourself with an example, because if you use the 'wrong team' it will give you less than the real distance. So taking the max() of these is optimal.Now that we are convinced that the formula works, between two points (r1, c1) and (r2, c2), if we build an office at point (r2, c2) we would like to iterate over all other points. But for every pair of points we will use the same equation. Each term of the equation is of the form:T = max(a — b, b — a). (because of the abs())So if we have fixed 'b', isn't better to take 'a' as large as possible or as min as possible ? Intuitively we want 'a' to be as far as possible from 'b'. So having the minimum and the maximum possible 'a' is enough, because for EVERY 'b' its always better to pick the maximum or the minimum 'a' rather than one in between (you can visualize it with a line).