### chokudai's blog

By chokudai, history, 6 months ago,

We will hold AtCoder Beginner Contest 166.

The point values will be 100-200-300-400-500-600.

We are looking forward to your participation!

• +77

 » 6 months ago, # |   +11 Thank you atcoder for the wonderful weekend !!
•  » » 6 months ago, # ^ |   +12 Your profile pic is itself wonderful !!
 » 6 months ago, # |   0 I wish it will be a good round！
 » 6 months ago, # |   0 Why so easy A,B,C,D,E?
•  » » 6 months ago, # ^ | ← Rev. 2 →   -53 Atcoder beginner contests are just a joke. Only 1-2 good problems (probably E and F) and others are just fillers. Atcoder beginner contests should be of Div-2 difficulty or atleast in-between Div-2 and Div-3.
•  » » » 6 months ago, # ^ | ← Rev. 2 →   +13 I think it's actually for Division 2. That's why it is called as Beginner's Contest
•  » » » » 6 months ago, # ^ |   -16 I think it's Div.3, because there are three kinds of regular contests: ABC, ARC, and AGC.
•  » » » 6 months ago, # ^ |   +38 Still, ABCs are good enough for a guy with 0 ratings.
•  » » » » 6 months ago, # ^ |   0 Anyone give me a counter test case where my logic fails for F. I have done a greedy approach , where for each string , I will increase the one with min value and decrease the one with maximum in b/w those two variables and storing the values accordingly and then printing.
•  » » » » » 6 months ago, # ^ |   +15 1 1 0 and AB. You need to know what comes next to make the right choice.
•  » » » » » » 6 months ago, # ^ |   0 yeah,thanks.got it!
•  » » 6 months ago, # ^ |   -17 I think F is easier than E. (I'm trying to solve F)
•  » » » 6 months ago, # ^ |   0 I solved it! I made 1600 points!
•  » » 6 months ago, # ^ |   0 D was very interesting.
•  » » » 6 months ago, # ^ |   +1 what's the solution for D??
•  » » » » 6 months ago, # ^ |   0 If answer exist(for given x there always exist a pair (A,B)). It will be -1000<=A<=1000 and -1000<=B<=1000. use two loop
•  » » » » » 6 months ago, # ^ |   0 why -1000 to 1000?
•  » » » » » » 6 months ago, # ^ | ← Rev. 2 →   0 Actually I took -1000 to 1000 for safety. but u can see (100)^5>1e9. U can take -120 to 120 too. It will also pass
•  » » » » » » » 6 months ago, # ^ |   0 Thank you so much
•  » » » » » » » 6 months ago, # ^ |   0 May be not I tried
•  » » » » » » » 6 months ago, # ^ |   0 say if the difference given to us comes at (1000)^5- (999)^5
•  » » » » » » » » 6 months ago, # ^ |   0 the number (1000)^5 — (999)^5 is greater than the possible range of values for x
•  » » 6 months ago, # ^ |   0 "B" in "ABC" stands for beginner.
•  » » » 6 months ago, # ^ |   -6 Even Div-3 contests in codeforces are also for beginners but they don't ask you to print the circumference of the circle with a given radius or swap 3 numbers.
•  » » » » 6 months ago, # ^ |   0 or just print what is said! AGC AND ARC are good by the way
 » 6 months ago, # | ← Rev. 2 →   +1 Why so much hate in this world cryGet AC on A, B, C, D, E and WA only on the last of the 60 tests of the F...
 » 6 months ago, # |   +21 ![ ]()
 » 6 months ago, # |   +26 How to solve F!
•  » » 6 months ago, # ^ |   +6 Keep alive this round, try to alive next round(Be careful when there are two 1, and one 0).
•  » » 6 months ago, # ^ |   +9 Always increase a smaller variable and decrease a greater one in a pair, except for the one case: when two variables you need to change are $1, 1$ and the third one is $0$, in this situation you have to choose what variable to increase depending on the next request in order to avoid a case like where you have $2, 0, 0$ and the next request is $BC$.
•  » » 6 months ago, # ^ |   0 Here's my solution.
 » 6 months ago, # |   0 How to solve problem E?
•  » » 6 months ago, # ^ | ← Rev. 4 →   +2 You need to use the frequency map, In first loop perform f[ i — a[i] ]++, and in second loop perform count += f[ a[i] + i ]. that's it
•  » » 6 months ago, # ^ | ← Rev. 2 →   +3 For two attendees to pair i-j = hi + hj (Assume i>j) should hold where i and j are indices of the attendees. Move both the i terms on i side and j terms on the other then it reduces to i-hi = hj + j. Which is equivalent to finding number of comment elements in two arrays by making arrays for both i-hi and the other as hj+j.
•  » » 6 months ago, # ^ | ← Rev. 3 →   0 E is pretty easy if you make the observation that for any j > i following condition has to holds, j — A[j] = A[i] + i. so keep a map to count the occurrence of A[i] + i observed till now. add the count of j — A[j] into the answer.solution
•  » » 6 months ago, # ^ |   0 You need to find number of pair of indices such that |j-i| = A[i] + A[j] . Assume j > i, then, you need to check which (i,j) satisfy j — A[j] = i + A[i].You can start iterating from left, keep a count of i+A[i] and for every new index j, do, ans+=count[j-A[j]]
•  » » 6 months ago, # ^ | ← Rev. 2 →   0 Store somewhere $(index_{i}+height_{i})$ and any index ask how many $(index_{curr}-height_{curr})$ already exist. add this to final $ans$. finally return the $ans.$
•  » » 6 months ago, # ^ | ← Rev. 2 →   0 We are considering j > i so we need to find all i and j such thatj - i = a[j] + a[i] which is a[j] - j = - a[i] - iso for each j we need find count all of those whose value - a[i] - i is equal to a[j] -j. We can use a map to store values of - a[i] - i and add it to our answer in each step for value a[j] - j.Code
•  » » » 6 months ago, # ^ |   0 got it.
•  » » 6 months ago, # ^ |   0 Just use the fact that A[i]+A[j]=abs(i-j) expands to i-A[i]=A[j]+j (atleast in positive value of abs sign). For the other one it'll cover cases by symmetry. No compute the two arrays with entries i-A[i] and j+A[j], store the counts of elements in a frequency map and return the answer. A simple solution is here
•  » » 6 months ago, # ^ |   0 An easy code to understand
 » 6 months ago, # |   0 why greedy for F fails? anyone Please?
•  » » 6 months ago, # ^ |   0 What do you do when both A and B are equal and next event is AB?For example: A = 1, B = 1 and C = 0 and event is AB.You need to check if next event is BC or AC and work accordingly. Can't just make anyone of it +1 and other -1.
•  » » » 6 months ago, # ^ |   0 Yeah for this I did offline thing. At every stage I checked if both are equal then which is having more query remaining. So the one with higher no of query remaining I add to it(give it priority)
•  » » » » 6 months ago, # ^ |   0 You should give priority to the next closest move, not to the most frequent among remaining. For example A = 1, B = 1, C = 0, and the sequence of moves is AB, AC, BC, BC, BC. On move AB you should add 1 to A, to make move AC possible, not to B, even though BC is more frequent.
•  » » » » » 6 months ago, # ^ |   0 yeah it worked.
 » 6 months ago, # |   +7 this F is not very hard,i think,but has a number of details to deal with.i finally got accepted after 5 tries with a loooooooooooooong code.
•  » » 6 months ago, # ^ |   0 I guess only 2 details to deal with no ? Check if one of them is 0 or both of them are 1. My code wasn't that long either : https://atcoder.jp/contests/abc166/submissions/12771073
•  » » » 6 months ago, # ^ |   0 oh,maybe i did a lot more usless things.you can see what i did here XD
•  » » » » 6 months ago, # ^ |   0 Well at least you got the AC haha it took me a while to think it through xD
•  » » 6 months ago, # ^ |   0 Can you share your detailed approach?
•  » » » 6 months ago, # ^ | ← Rev. 3 →   0
 » 6 months ago, # |   +6 Got 457 lines of code in F)
•  » » 6 months ago, # ^ |   +46 F
 » 6 months ago, # |   0 E anyone?
•  » » 6 months ago, # ^ |   0 Start traversing a from back to front and at each i from $1$ to $N$ keep count of $i$-$Ai$ and check how many previous elements are there with current sum $i$+$Ai$.My Solution
•  » » 6 months ago, # ^ |   0
 » 6 months ago, # | ← Rev. 2 →   0 I had a lot of TLEs with my solutions for this contest. For example, here is my code for problem E (C++): #include #include #include #include using namespace std; int main(){ int N, count=0; cin>>N; int att[N]; for(int i=0; i>att[i]; } for(int i=0; i
•  » » 6 months ago, # ^ |   +1 Your code has a complexity of O(N^2) and N is 1e5. So that is why you are getting TLE.
•  » » » 6 months ago, # ^ |   0 I see. Thank you! I'll review my other solutions that got a TLE to see if they have the same problem.
•  » » 6 months ago, # ^ |   0 This is clear O(n^2). See the constraints. n<= 2*10^5. simplify the expression |id1-id2|=a[id1]+a[id2] ==> id1-id2= -(a[id1]+a[id2]) maintain LHS and RHS in different arrays and just count how many times element from LHS array occurs in RHS array. My Submission
•  » » 6 months ago, # ^ |   0 TLE = Time limit exceeded.Checking every possible pair (complexity O(N^2)) is not efficient enough for such a big value of n as 2*10^5.
•  » » 6 months ago, # ^ |   0 try an O(n) solution
 » 6 months ago, # | ← Rev. 3 →   0 What is the approach for F?I tried defining each of the 8 choice possibilities (For AB choose A first or B if both remain, similary for AC and BC) at the start and check if it works. Do you have to do something like this at each step and maintain an 8 * n DP or something like that?
•  » » 6 months ago, # ^ |   0 My solution was to choose such an option that I will survive current and also next round. If both choices are survivable then go greedy.
•  » » 6 months ago, # ^ |   +1 You could just run a DFS and check if you can reach a path of length n. Start with state a,b,c and then at each point proceed to a 2 posibble state given by choice[i].Here is my submission: https://atcoder.jp/contests/abc166/submissions/12776155
•  » » » 6 months ago, # ^ |   +6 isn't the complexity of your code 2^n?
•  » » » » 6 months ago, # ^ |   0 Yes, it seems like an oversight that these solutions pass?It even works in Python:https://atcoder.jp/contests/abc166/submissions/12781991
•  » » » 6 months ago, # ^ |   0 How is your code working but not this simple recursion? Aren't they of the same complexity https://atcoder.jp/contests/abc166/submissions/12784875
•  » » » » 6 months ago, # ^ |   +4 It's because you're not passing references to your function, it creates a copy which take time for each call. you can find your accepted version here
•  » » » » » 6 months ago, # ^ |   0 Thanks a lot for helping! Learnt something new. Nice of you to help so many beginners in the comment section.
•  » » » » » » 6 months ago, # ^ |   0 We're all beginners in some way, glad I could be of help
•  » » » » » » 6 months ago, # ^ |   0 Wow!! I didn't know this! Thanks for such discussions.
•  » » 6 months ago, # ^ | ← Rev. 2 →   0 I tried with 27*n dp but it failed
•  » » » 6 months ago, # ^ |   0 Any one passed using dp?
•  » » » 6 months ago, # ^ |   0 i did a 64*n dp which got AC.
•  » » » » 6 months ago, # ^ |   0 can you share your approach. Also explain your dp states
•  » » » » » 6 months ago, # ^ |   +11 I have similar (maybe even the same approach) — you can notice that we don't care what a value is if it's bigger than 3, so we can have states (position, a, b, c), and after each step a = min(a, 3) and so on. You have 64 * n states and two transitions from each state. Here's my code https://atcoder.jp/contests/abc166/submissions/12752950
•  » » » » » » 6 months ago, # ^ |   +9 we don't care what a value is if it's bigger than 3. I think we can make a=min(a,2), with 27*n states is also acceptable. my submission
•  » » » » » » » 6 months ago, # ^ |   0 is keeping pre computed dp in your second recursive function also work?
•  » » » » » » » » 6 months ago, # ^ |   0 I don't get it perfectly what you are asking, but second recursive function is for printing path, and yes precomputed dp works in that.
•  » » » » » » » » » 6 months ago, # ^ | ← Rev. 2 →   0
•  » » » » » » » » » 6 months ago, # ^ |   +3 It works fine, I see your submission, In second recursive function when you are comparing (dp[in+1][a-1][qq][c]==1) here you have to add condition that a-1>=0 same in other 2 If statement also. corrected your submission
•  » » » » » » » » » 6 months ago, # ^ |   0 thanks.
•  » » » » » » 6 months ago, # ^ |   0 Can you share your intuition behind why don't we care for values that are greater than 3 (or 2)? Why just taking 3 would do? I understand by looking at examples but am not able to wrap my head around it. It would help if you could share your intuition perhaps.
•  » » » » » » » 6 months ago, # ^ |   +1 This whole idea came to me when I noticed that configuration "1 1 1" is always correct if we choose greedy approach (add 1 to smaller of two). That led me to conclusion, that if sum is bigger or equal to 3 (unless it's 3 0 0 and operation is BC) is always correct as well. Connect this with pretty natural DP solution and you get my solution. If you have more questions feel free to ask
•  » » 6 months ago, # ^ |   +15 Greedy approach can get AC, You only need to check a couple of things first : If one of them is 0 you have to add it +1. If both of them 1, you need to check which one comes next first, for example if the order is AB then BC ( A = 1, B = 1, C = 0 ) you have to add +1 to B otherwise you add it to the other. If you're not in any of the other cases you can just add +1 to the minimum of them. Keep checking if one of them is less than 0 return No
•  » » » 6 months ago, # ^ |   0 why does this work
•  » » » » 6 months ago, # ^ |   +3 It can be easily shown if one value is greater than the other, it's safe to increase the min value. Our only concern is when both values are equal to 1, that way one of them will become a zero, we need to know which one to increase. The choice is based on which value will be used again first. Same example as the last comments : A = 1, B = 1 and C = 0 it will depend on the order. Suppose the order is : AB then BC, if we increase A our solution will fail. And if the order is : AB then AC then if we increase B our solution will fail too. It is clear that we need to increment the value that comes next first in that case.
•  » » » » » 6 months ago, # ^ |   0 got it, thanks a lot.
•  » » » 6 months ago, # ^ | ← Rev. 2 →   0 UPD : Deleted
 » 6 months ago, # |   +24 For F I did complete search using recursion and it passed. Can anybody explain why?
•  » » 6 months ago, # ^ |   +8 Maybe Highly optimized,choose the right answer first, so it succeed when first get into end state.
•  » » 6 months ago, # ^ |   +7 Can you share your code?
•  » » » 6 months ago, # ^ |   +5
•  » » 6 months ago, # ^ |   +1 It all comes to when is the answer No : The only possibility it fails is if there are 3 zeros or 2 and a certain ordering to make it fail. That being said, The answer can be found fast enough for both cases.
 » 6 months ago, # |   +3 can someone help me in problem D ?
•  » » 6 months ago, # ^ |   0 D is quite easy. You just need to use brute force and compute all fifth powers of numbers from -1000 to 1000, and then you can use an O(n^2) algorithm to see if x is equal to the difference of any two. Code
•  » » » 6 months ago, # ^ |   +5 pff i feel so stupid !! thanks bro
•  » » » 6 months ago, # ^ |   0 In my first atempt i used 100 instead of 1000, and it failed. But the 1000 was only a lucky guess.How would we find the correct minimum number?
•  » » » » 6 months ago, # ^ |   +6 Find the smallest number x for which (x^5-(x-1)^5) > 1e9.I think it comes around 120.
•  » » » » 6 months ago, # ^ |   0 I guess look at $b=a-1$ for boundary condition because that minimise $x$ for given $a$. I tried $100$ because I misread number of digits in $100^5-99^5$. Then I used $200$ and it passed.
•  » » » » 6 months ago, # ^ |   0 for (i in range 0 -120 ) for (j in range -64 i-1) if (i^5 -j^5==x) — done You can find detail here
•  » » 6 months ago, # ^ | ← Rev. 2 →   -6 I don't have a strong proof as to why will there always be a pair less than |a| , |b| <= 10^3 but had some intuitive feeling and it ACed Codeint power(int x,int b){ return x*x*x*x*x; } void solve() { int x ; cin>>x; int a = 0, b = 0; for(int a=-1000;a<=1000;a++){ for(int b = -1000; b <= 1000; b++){ if(power(a,5) - power(b,5) == x){ cout<
•  » » » 6 months ago, # ^ |   0 x^5 — (x-1)^5 is an increasing function for postive integers. The first time its value crosses 10^9 is when x is around 10^12.
 » 6 months ago, # |   +16 English Editorail of F Three Variables Game • When A + B + C = 0, N is 1 or more, so the answer is No. • When A + B + C = 1, at least one of the two variables is zero at any time, so the action on each turn is uniquely determined. • When A + B + C> = 2, the answer is No if the variables added and subtracted in the first turn are both zero, otherwise the answer is Yes. In the latter case, you can keep one of the variables being added positive by taking the following strategy each turn. {When one of the variables to add and subtract is zero and the other is positive, add one to the one that is zero and subtract one from the other. (A + B + C = 2, the variables to add and subtract are both 1, and when the character string of the next turn and the character string of the current turn are different, not the last turn, the character addition and subtraction of the next turn is performed. Add 1 to the variable you plan to do and subtract 1 from the other. {Otherwise, select appropriately
 » 6 months ago, # |   0 What wrong in my code for the problem D x=int(input()) value=0 index=0 hashmap=dict() while value
•  » » 6 months ago, # ^ |   0 Your limits are too small, you can subtract values so you may need values greater than 1e9. Your code with greater limits get AC. I don't know how to find the correct limits.
•  » » » 6 months ago, # ^ |   0 oho shit thank you
 » 6 months ago, # |   +3 the language of D and E was so clear still couldn't solve it, got WA on last test case of E and TLE on D. I like atcoder's format easy language difficult task .makes these problems more approachable. Thanks Atcoder
•  » » 6 months ago, # ^ |   0 In E you can see a pattern emerge... Try to map the sum of the index of first element and height of the first element with:The difference in the index of the second element and its height. Store the sum of the index and height of first element in the map in one pass. In the second pass count how many occurrences of the index — height is present in the map. Be sure to take Long. I got WA due to that.. Here is my solution: https://atcoder.jp/contests/abc166/submissions/12778280
•  » » » 6 months ago, # ^ | ← Rev. 3 →   +1 thank you! https://atcoder.jp/contests/abc166/submissions/12786984 solved it in 53 ms
 » 6 months ago, # |   +17 Yay I full solved all 6 problems with 0 incorrect attempts!Timing was slow though :(
 » 6 months ago, # |   +1 I thought the problem statement on B was not clearly defined. Otherwise, it was such a great contest! got WA on both D and E because I did not take long. Feel like killing myself :( Gonna upsolve F now.
 » 6 months ago, # |   +12 I solved D by expressing A^5 — B^5 as (a − b)(a^4 + a^3*b + a^2*b^2 + a*b^3 + b^4).At this point, I iterated over all possible divisors. Since a-b < (the term consisting of all positives), I only had to check the divisors less than sqrt(X). Then, once a-b was set, I binary searched to find the value of b (if any) to satisfy the expression.My final runtime: optimized O(sqrt(X)*log(X))
•  » » 6 months ago, # ^ |   0 You can also check if A^5-B^5 equals to x for all a and b from -200 to 200. It's faster.
•  » » » 6 months ago, # ^ |   0 It can be -120 to 120.
•  » » 6 months ago, # ^ |   0 Wow so there exists a good way to do this thanks.
•  » » 6 months ago, # ^ |   0 can you share your code
•  » » » 6 months ago, # ^ |   0 This code is easier Code just check from -1000 to +1000 because if a = 1001 the minimum positive result is b = -1000 and the result is 1.0004901e+20 and it's bigger than x
•  » » » » 6 months ago, # ^ |   0 It can be -120 to 120, 120^5-119^5=1,019,663,401, it's bigger than 1e9.
•  » » 6 months ago, # ^ |   0 Yeah I also did first part of your method, but I think it was overkill when I looked at $100^5-99^5$. So I wrote the easy brute force.
•  » » 4 months ago, # ^ |   0 what do you mean by term consisting of all positives ?I didn't get this part: Your Code: for (int j = -500; j <= 500; j++) { long a = j+i; long b = j; if (a*a*a*a*a-b*b*b*b*b == X) { pw.println(a + " " + b); pw.close(); return; } } 
 » 6 months ago, # |   0 Can anyone explain D solution?
•  » » 6 months ago, # ^ |   0 A and B values lie between -1000 and 1000. So you can brute forces using two loops and find if A-B==X. you can print that A and B value.
 » 6 months ago, # |   +1 In codeforces https://codeforces.com/contest/1345/problems we get list of all problems, how to do the same in atcoder, like all the task they appear in the same page. If anyone knows please comment the link of that page where all task appear on one page.
•  » » 6 months ago, # ^ |   +4 You could use kenkoooo for that.
•  » » » 6 months ago, # ^ |   +4 Thanks it's an awesome site. I too found the page where like all task of a particular contest appear — https://atcoder.jp/contests/abc165/tasks_print Format — https://atcoder.jp/contests/"contest_name"/tasks_print
•  » » » » 6 months ago, # ^ |   0 Oh, I got you wrong then :)
 » 6 months ago, # | ← Rev. 2 →   0 I overkilled F with dp, followed by 14-15 RTE's :(PS: Atcoder could really work to differentiate between MLE and RTE.
•  » » 6 months ago, # ^ |   0 Here is my solution to problem F using DP.
 » 6 months ago, # |   0 Solution in simple words:A. Just check the input string.B. Compute the food each person has. One can use a frequency array to do this.C. Iterate through all paths. Each path makes one observatory non-peak (or two, if they have same height).D. Since $a^5 - b^5 = X > 0$, we have $a > b$, that is $b \leq a - 1$. So $a^5 - (a - 1)^5 \geq a^5 - b^5 = X$. Obviously $f(x) = x^5 - (x - 1)^5$ is increasing when $x > 1$ and decreasing when $x < 0$, so we can find the upper and lower bound of $a$ from $X$. Simply enumerate all possible $a$'s and check if $a^5 - X$ is the fifth power of some integer. This can be done with precomputing all fifth powers in the potential range. In practice we can use a looser bound to estimate the range of $a$.E. Consider the number of pairs $(i, j)$ satisfying $i < j$ and $A_i + A_j = j - i$. Fix $j$, the number of $i$'s pairing with $j$ satisfying $A_i + i = j - A_j$. Just iterate from left to right and keep the frequencies of all $A_i + i$.F. In each operation we can greedily take $1$ from the greater number and add $1$ to the smaller one. The only exception is there being two $1$'s and one $0$ and we are going to operate on the $1$'s. We have to create another $0$ in this operation, so we need to consider the next operation in order to make it doable. The answer is No if any operation creates a negative number.
•  » » 6 months ago, # ^ |   0 https://atcoder.jp/contests/abc166/submissions/12790626Will you help me with problem F.I am failing with killer test cases.
•  » » » 6 months ago, # ^ |   0 But the code is .... lol
•  » » 6 months ago, # ^ |   0 https://atcoder.jp/contests/abc166/submissions/12803726 i am getting wrong ans on killer test 5 Can somebody help me out. It is for problem F atcoder 166
 » 6 months ago, # | ← Rev. 2 →   0 what is said in problem B !! did not get it guys!
•  » » 6 months ago, # ^ |   0 There are N snukes and K kinds of snacks. From the second line to the last line, in every two lines it gives how many and which snuke does the i snack have.You just need to find the number of the snacks which have no snuke.
 » 6 months ago, # | ← Rev. 2 →   0 I used normal bruteforce approach for problem D. It worked fine for 31,32,33 but for any other input value it gave no output. I used codechef ide,hackerearth ide,ideone,gfg ide but in all it gave no output. Then I took an AC code and try getting ans for random input between 1 to 1e9 but it also gave no output.And when I submitted my same code it got AC on atcoder. Pls can anybody tell what may be the reasons?
 » 6 months ago, # |   0 My python solution12793022I am getting WA for one test case (killer_05.txt). Can somebody please tell me what am I missing? Thank you.
•  » » 6 months ago, # ^ |   0 same here
 » 6 months ago, # |   0 I would appreciate it if someone provide me the English editorial.QwQ
 » 6 months ago, # |   0 https://atcoder.jp/contests/abc166/submissions/12803726 i am getting wrong ans on killer test 5 Can somebody help me out. It is for problem F atcoder 166
•  » » 6 months ago, # ^ | ← Rev. 2 →   0 I read it a bit fast but I think your mistake is in this case: "if(a[id1]==a[id2] && a[id1]==1 && a[id3]==0)".You are not taking into consideration the other special case where a[id2]=1 and a[id3]=0. Also the way you are searching for the future cases is wrong because you assign a char variable to a string one.Generally, I think that you only need to check for equality and increase the a[id], which is the one that will participate in a future choice sooner than the other.
 » 6 months ago, # |   0 can someone tell what's wrong in my solution for problem C https://atcoder.jp/contests/abc166/submissions/12819281
 » 6 months ago, # |   0 For D — detail explanation and reduced range of searching with code Here