### Supermagzzz's blog

By Supermagzzz, 10 days ago, translation,

Hello, Codeforces!

<almost-copy-pasted-part>

Hello! Codeforces Round #702 (Div. 3) will start at Feb/16/2021 17:35 (Moscow time). You will be offered 7 problems with expected difficulties to compose an interesting competition for participants with ratings up to 1600. However, all of you who wish to take part and have a rating 1600 or higher, can register for the round unofficially. The round will be hosted by rules of educational rounds (extended ICPC). Thus, during the round, solutions will be judged on preliminary tests, and after the round it will be a 12-hour phase of open hacks. I tried to make strong tests — just like you will be upset if many solutions fail after the contest is over.

You will be given 7 problems and 2 hours to solve them.

Note that the penalty for the wrong submission in this round (and the following Div. 3 rounds) is 10 minutes.

Remember that only the trusted participants of the third division will be included in the official standings table. As it is written by link, this is a compulsory measure for combating unsporting behavior. To qualify as trusted participants of the third division, you must:

• take part in at least two rated rounds (and solve at least one problem in each of them),
• do not have a point of 1900 or higher in the rating.

Regardless of whether you are a trusted participant of the third division or not, if your rating is less than 1600, then the round will be rated for you.

The problems for this round were invented by MikeMirzayanov, Supermagzzz, Stepavly and sodafago.

Thanks to MikeMirzayanov for platforms and coordination of our work. Thanks to darkkcyan, Sho, sodafago, Nebuchadnezzar, kocko, akagami_no_shanks, Gassa, infinitepro, bfs.07 for help in round preparation and testing the round.

Good luck!

</almost-copy-pasted-part>

UPD: Editorial is ready!

• +254

 » 10 days ago, # |   +2 Every announcement of Div3 round from Supermagzzz, Stepavly and MikeMirzayanov makes me happy!
 » 10 days ago, # |   +87 As a
•  » » 10 days ago, # ^ |   +13
 » 10 days ago, # |   -10 Good luck everyone !!!
 » 10 days ago, # |   -20 Sick, I miss div 3 contests so much, looking forward to participating into this!
 » 10 days ago, # | ← Rev. 4 →   -39
•  » » 10 days ago, # ^ |   +5 Why you guys stealing memes ???
•  » » » 10 days ago, # ^ | ← Rev. 3 →   -16 I'm Batman
•  » » » 10 days ago, # ^ |   +2 Because MOSS doesn't run here :P
•  » » » » 10 days ago, # ^ |   -6 I think $e^{\pi i} + 1 = 0$ is funny to you.
•  » » » » » 10 days ago, # ^ |   0 Not as much as cin>>name; would be for you!
•  » » » » » » 10 days ago, # ^ |   -9 I stay away from people who uses using namespace std.
 » 10 days ago, # | ← Rev. 2 →   -15 is div3 rated for someone with current rating < 1600 but his max rating >= 1900 ??Edit : sorry i didn't see this Regardless of whether you are a trusted participant of the third division or not, if your rating is less than 1600, then the round will be rated for you.
•  » » 10 days ago, # ^ |   0 It's based on current rating only. Max rating doesn't make a difference.
•  » » » 10 days ago, # ^ |   -18 so what about this point do not have a point of 1900 or higher in the rating. ?? what do they mean of trusted participants ?
•  » » » » 10 days ago, # ^ |   +32 Accounts that have reached a rating >= 1900 at any point can safely be assumed to belong to the stages beyond amateur grade. Therefore, having them part of the "official standings table" that is published is likely to distort the actual standings list.Similarly, new accounts could be alts to high rated coders as well and including those would lead to similar results.Therefore, while the round will be rated for anyone below 1600 (at the time of the contest, I believe — or maybe registration, this is actually my doubt as well). The official standings list published simply won't contain the names of these "participants that may not be trusted as div 3 folk"
•  » » 10 days ago, # ^ |   -22 I'm quite surprised that you had $203$ contests and you still didn't know.
 » 10 days ago, # |   +7 Is the rated cap for rounds based on the user's rating at the time of the contest or at the time of the registration?I tried searching for some relevant blog but couldn't find one.. Thanks in advance :)
•  » » 9 days ago, # ^ |   +6 At the time of the contest rather.Calculation of rating, finalization of winners board logic happens after contest as well as validation of being trusted participant and/or below 1600 member.
•  » » » 9 days ago, # ^ |   +3 Thank you very much for the clarification :)
 » 10 days ago, # |   +148
•  » » 10 days ago, # ^ |   +27 true story
•  » » 10 days ago, # ^ |   +11 it is relatable . my mom 's TV sound !! is high everytime i give contest
•  » » 10 days ago, # ^ |   0 F
•  » » 10 days ago, # ^ |   +4 The contest starts at 22:35 in CST(UTC +8). That is the time my family go sleep.
•  » » 10 days ago, # ^ |   +19 Ah.. Stop farming contribution by someone else's ideas
•  » » » 10 days ago, # ^ | ← Rev. 2 →   -10 .
•  » » » » 9 days ago, # ^ |   +5 Can't you count to 2?
•  » » » » » 9 days ago, # ^ |   -9 I just asked that if 2-gon is the international grandmaster 1-gon.. caz many pros make new accounts to give the lower rated contests... but everyone was downvoting it for no reason... N whats up with u man..its not binary. U can be a good coder n polite at the same time!!!! Now dont get overexcited u r just a pupil. Some 150 points more than me!!!!!!
•  » » » » » » 9 days ago, # ^ | ← Rev. 2 →   +3 Stop attacking me — I did not downvote you, I promise. :)
•  » » 10 days ago, # ^ |   +2 Same scene at my home. People having loud fun chat and me struggling to concentrate on how to solve the question
•  » » 10 days ago, # ^ |   +1 OMG it's true
•  » » 9 days ago, # ^ |   +2 The most relatable meme that I've ever seen in the comment section this far.
•  » » 9 days ago, # ^ |   0 Same, if you got WA then its very frustrating to think about.
 » 10 days ago, # |   +26 Yah Codeforces Hey!Yah hum coders hey Yaha Cowding ho rahi hey!
•  » » 10 days ago, # ^ |   +8 What do you mean?
•  » » » 10 days ago, # ^ |   0 It's a play on a viral video from the subcontinent (the South Asian region)
 » 10 days ago, # |   0 Finally, a div3 round that I missed so much
•  » » 10 days ago, # ^ |   0 Codeforces is luv....!
 » 10 days ago, # |   +95
•  » » 10 days ago, # ^ |   +4 this happens every single time F
•  » » 10 days ago, # ^ |   +1 What happen if a person whose rating will be more than 1600 after Educational round = )))
 » 10 days ago, # | ← Rev. 2 →   0 1
 » 10 days ago, # |   0 Previous rating change unrolled, will this contest be rated for me ?
•  » » 10 days ago, # ^ | ← Rev. 2 →   0 Not sure. They'll re-check your rating 5 mins before the contest starts.
•  » » 10 days ago, # ^ |   0 Never mind!
 » 10 days ago, # |   +88
 » 10 days ago, # |   +1
 » 10 days ago, # |   0 Judging by my very poor performance of the last round(spoiler: never enter a round 40 minutes after it started:)) i think that this round should be rated for me. Are the new ratings coming until the start of this div3?
•  » » 10 days ago, # ^ |   0 Yep. might be updated in few hours.
•  » » » 10 days ago, # ^ |   0 only 1 hr left . I hope soon now ..
•  » » » » 10 days ago, # ^ |   0 I assure you the rating will be updated as soon as this comment gets -69.
 » 10 days ago, # |   +7 will the new ratings come before div3 or not ??
 » 10 days ago, # | ← Rev. 2 →   +1 From the last contest there seems to be less participation because of busy schedules and lot of assignments of college.
•  » » 10 days ago, # ^ |   +1 Same
 » 10 days ago, # |   +2 As a participant, I wish no "Wrong Answer On Test x" situation.
 » 10 days ago, # |   0 is there any other div. 3 contest i have work so i usually cant participate in this one
 » 10 days ago, # |   +3 This is my first time to compete in CF. good luck. 祝我好运！
•  » » 10 days ago, # ^ |   0 ¡Buena suerte!
 » 10 days ago, # | ← Rev. 4 →   -13 Okay
 » 10 days ago, # |   +1 Wait is over ❤ Finally div 3 after long time
 » 9 days ago, # |   0 Goodluck, everyone <3
 » 9 days ago, # |   0 Thank you ! perfect time for div3
 » 9 days ago, # |   +2 Wtfffff Muffinhead 6 problems in 9 minutes how is this even possible !!
•  » » 9 days ago, # ^ |   0 It seems that codeforces recognized him as a cheater because he is not on the scoreboard anymore.But I think that he his Benq with another account any ideas?
•  » » » 9 days ago, # ^ |   0 Even for a legendary grandmaster that's too fast but that's weird why would he participate in unrated contest from another account
•  » » » » 9 days ago, # ^ |   0 I think it happened once before , remember that video on William lin's channel
 » 9 days ago, # |   0 I am unable too see problems or register can someone help?
 » 9 days ago, # |   +1 Positive delta YES!!!!
 » 9 days ago, # |   +18 Is it just me or these div3 rounds have become wayy too easy.
•  » » 9 days ago, # ^ |   +4 Or you have become better?
•  » » » 9 days ago, # ^ |   +1 I don't think so maybe it's just more suitable for the target audience these days.
•  » » » » 9 days ago, # ^ |   0 A Supermagzzz round is an ez roundI think they actually seem easier than the older div3s, especially with the 7-problem format.
•  » » 9 days ago, # ^ |   +8 I think first few are harder while the last few are easier, nice problems overall.
•  » » 9 days ago, # ^ |   +1 and here I am couldn't solve even "A"...don't know what's going wrong :(
 » 9 days ago, # |   +25 is this a div4?
•  » » 9 days ago, # ^ |   +1 I think, it's just real div3
 » 9 days ago, # | ← Rev. 2 →   0 wrong answer using segment tree on g why? Here:107616153
•  » » 9 days ago, # ^ |   +17 Seriously, how do you expect people to understand your solution just by hinting with some topic.
 » 9 days ago, # |   +6 invented ! =discovered.
 » 9 days ago, # |   +11 Supermagzzz's DIV 3 are easier as compared to vovuh's.
•  » » 9 days ago, # ^ |   +7 bro more than 2700 people solved F. that's crazy
 » 9 days ago, # |   +11 speedforces :(
 » 9 days ago, # |   +3 I was not particularly quick today but still solved all problems and recorded a screencast with explanations
 » 9 days ago, # |   +11 The difficulty from A-E is in decreasing order
•  » » 9 days ago, # ^ |   +1 Very true, F was way easier than A and B
 » 9 days ago, # |   +5 Felt more like a Leetcode Contest without its final problem
 » 9 days ago, # | ← Rev. 2 →   0 how the answer for this A test is 3? 124 31 25 50 30 20 34 46 42 16 15 16
•  » » 9 days ago, # ^ | ← Rev. 3 →   0 4 8 16 31 25 50 30 20 34 46 42 21 16 15 168, 6, 21 are added.
•  » » » 9 days ago, # ^ | ← Rev. 2 →   0 someone can tell me why A solution https://codeforces.com/contest/1490/submission/107622033 this failing? what i should change to make it correct?
•  » » » » 9 days ago, # ^ | ← Rev. 3 →   0 One this test case 1 12 4 31 25 50 30 20 34 46 42 16 15 16 Your code will update the array 4 times as 8 31 25 50 30 20 34 46 42 16 15 16 16 31 25 50 30 20 34 46 42 16 15 16 16 31 25 50 30 20 34 46 42 32 15 16 16 31 25 50 30 20 34 46 42 32 30 16 However, the last update isn't necessary. 32 isn't adjacent with 15, it is with 16. If you implemented to code to add the values instead of updating them. The list changes would be 4 8 31 25 50 30 20 34 46 42 16 15 16 4 8 16 31 25 50 30 20 34 46 42 16 15 16 4 8 16 31 25 50 30 20 34 46 42 32 16 15 16 
•  » » » » » 9 days ago, # ^ |   0 thnk you brother. i understodd the mistake
 » 9 days ago, # |   0 Can't we solve problem f without using the concept of hashing? initially, I was thinking to declare an array of size 10^9. later realized that it would give any runtime error or memory limit exceed.Is there any way other than hashing or map to solve f ?
•  » » 9 days ago, # ^ |   0 you can store the numbers in an array, sort it and then count how many there is for a given value but it's nlog n
•  » » 9 days ago, # ^ |   0 I solved it using Treemaps but Yes You can easily convert it to hashmap solution.
 » 9 days ago, # |   +1 My solution for problem C outputs "NO" in my local device while outputs "YES" when I submit, for input 34. It tried with brackets also, but results are the same. It showing 'wrong answer for test 1'.my solution is: https://codeforces.com/contest/1490/submission/107615310
•  » » 9 days ago, # ^ | ← Rev. 2 →   0 I tried it on Custom Invocation and it gives "NO" on GNU G++ 17 9.2.0 (64 bit), and "YES" in other C++ compilers.
•  » » 9 days ago, # ^ |   0 I got Yes on c++17 64 bithttps://codeforces.com/contest/1490/submission/107621338
 » 9 days ago, # |   0 Why this solution (for problem F) TLE on test 2. I think the time complexity is O(nlogn): https://codeforces.com/contest/1490/submission/107618301
•  » » 9 days ago, # ^ |   +5 The time complexity is O(t * MAXN) where MAXN is 2e5, so you got TLE.
 » 9 days ago, # |   0 Does someone know a test where this solution for G might fail? : https://codeforces.com/contest/1490/submission/107619800
 » 9 days ago, # |   0 is all problem of div 3 is of equal points or C(poihnts)>B
•  » » 9 days ago, # ^ |   0 Equal Points
 » 9 days ago, # |   +2 Spent 35 minutes on this bug. fml.
 » 9 days ago, # |   +6 What the heck is Unexpected verdict
•  » » 9 days ago, # ^ |   0 Inside the system there are solutions marked as correct solutions. If one of these solutions fail on a hack (maybe cause of WA, RTE, TLE, MLE, ...) then the hack is marked having "Unexpected verdict".When it happens, then just wait for a little while. Usually the problem setters fix it pretty quickly.
 » 9 days ago, # |   0 Problem C why my hacking verdict is 'Unexpected verdict' Input : 100 1000000000000 1000000000000 1000000000000 1000000000000 1000000000000 ... 
•  » » 9 days ago, # ^ |   0 Maybe that solution has been hacked before.
 » 9 days ago, # |   0 Different problem statements, but very similar question to E
•  » » 9 days ago, # ^ |   0 can you provide link
 » 9 days ago, # |   0 BinarySearchForces :3
 » 9 days ago, # |   +2 Finally very good Div.**3** contest! All who are Div.2-level could solve almost all problems.
 » 9 days ago, # |   0 How to Solve G?
•  » » 9 days ago, # ^ |   +5 if( prefix_sum[index_j] == xi ) ans = index_j — 1 else if , for some positive integer k if prefix_sum[index_j] + k*prefix_sum[n] = xi or in other words prefix_sum[index_j] is congruent to x mod prefix_sum[n] then , ans = k*(xi-prefix_sum[index_j])/prefix_sum[index_j] + index_j-1; store prefix_sum and prefix_sum % prefix_sum[n] in map to query
•  » » » 9 days ago, # ^ |   0 Okkk Thanks
•  » » 9 days ago, # ^ |   0 Create prefix sum $s_1,..,s_n$. The condition for which the result is -1 is $s_n\leq 0$ and $x > sm = max_{i=1..n}s_i$. Otherwise, if $x\leq sm$, find smallest index $i$ that $s_i\geq x$, the answer is $i-1$. For the last case where $x>sm$ and $s_n>0$. Let $p$ be the smallest value such that $p*s_n+sm \geq x$, the answer is $p*n + i'-1$ where $i'$ is the smallest value that $s_{i'} \geq x -p*s_n$. You can find $i$ by segment tree.
•  » » » 9 days ago, # ^ |   0 Okkk Thanks.
•  » » 9 days ago, # ^ |   0 link to my submission (obviously upsolved) without using Segment Tree. https://codeforces.com/contest/1490/submission/107636300
 » 9 days ago, # | ← Rev. 3 →   0 Can some one tell me where I am wrong in problem B. Spoilerfor testis in range(int(input())): n = int(input()) l = list(map(int, input().split())) ll = [] for i in l: ll.append(i%3) c0 = ll.count(0) c1 = ll.count(1) c2 = ll.count(2) d = n//3 #print(c0,c1,c2) #print(d) m = max(c0,c1,c2) if m==c0: ans = c0-d if c1+c0-d>d: ans = ans + c1 + c0 -d - d else: ans = ans + 2*(d - c1-c0 +d) elif m==c1: ans = c1-d if c2 + c1-d>d: ans = ans + c2 + c1 -d -d else: ans = ans + 2*(d - c2 -c1 +d) else: ans = c2-d if c0 + c2 -d >d: ans =ans + c0 + c2 - d -d else: ans =ans + 2*(a - c0 - c2 +d) print(ans)I am just removing the extra part (present count — the equal number of c0,c1,c2 that shud be there) from maximuum of c0,c1,c2 and adding it to next one among them ..and then again removing the extra from that part and adding it to next part. But I ma getting WA on runtime error on tc 2. ples help Thanks in advance.
•  » » 9 days ago, # ^ |   0 Testcase where your code would fail:6 3 3 3 2 2 2Answer is 2, but your code would give 0.
•  » » » 9 days ago, # ^ |   0 how is the answer 2 ?
•  » » » 9 days ago, # ^ |   0 How is it two? One two has to be increased twice and one 3 has to be increase once. So shouldn't it be 3?
•  » » » » 9 days ago, # ^ |   0 Sorry my bad, yes it should be 3 not 2.
•  » » » 9 days ago, # ^ | ← Rev. 2 →   0 dude my code is also giving answer 3, on this test case. I am getting runtime error and I am not getting whats the issue. ples help
 » 9 days ago, # |   0 Easy round, but I found my mistake on G 3 minutes before the end :(
 » 9 days ago, # |   +4 Bruteforces!!
 » 9 days ago, # |   +1 Those who have just started reading Binary Search , they must try to solve problems C , E , G. All 3 of them decent problems to start with.
 » 9 days ago, # |   0 107615789 why this code didn't get tle ?
 » 9 days ago, # | ← Rev. 2 →   0 if(c2>n/3) { c0=c0+c2-n/3; cout<<(c2-n/3)+abs(c0-n/3)<<"\n"; } else { c1=c1-(n/3-c2); cout<<(n/3-c2)+abs(c1-n/3)<<"\n"; }//why this logic is wrong in question B
 » 9 days ago, # |   0 Why this logic is wrong in question B ~~~~~ if(c2>n/3) { c0=c0+c2-n/3; cout<<(c2-n/3)+abs(c0-n/3)<<"\n"; } else { c1=c1-(n/3-c2); cout<<(n/3-c2)+abs(c1-n/3)<<"\n"; } ~~~~~
 » 9 days ago, # |   0 if(c2>n/3) { c0=c0+c2-n/3; cout<<(c2-n/3)+abs(c0-n/3)<<"\n"; } else { c1=c1-(n/3-c2); cout<<(n/3-c2)+abs(c1-n/3)<<"\n"; } Why this approach is wrong in B
•  » » 9 days ago, # ^ |   +1 What if c2==n/3 and c1 is not equal to n/3
 » 9 days ago, # |   -10 https://youtu.be/lEOz-It922wVideo solution for A. Dense Array
 » 9 days ago, # |   +16 Here’s my attempt to screencast this Div3 contest, where I have explained the solutions to the problems later. It’s my first ever screencast, and any suggestions would be helpful.https://www.youtube.com/watch?v=fbv5NKA9t9cI hope you like it.
 » 9 days ago, # |   0 Never solved 6 problems before. Thank you div3, finally I am able to achieve.
 » 9 days ago, # |   0 Is this round rated ? as it is showing in unrated contest in my performance graph in profile section
•  » » 9 days ago, # ^ |   0 It's rated. I don't know why it shows that for now.
 » 9 days ago, # |   0 Unfortunately, D was much easier than the first three problems. T_T
 » 9 days ago, # |   +9 G is a harder version of this problem
 » 9 days ago, # |   -14 I uploaded a screencast: https://youtu.be/InbURHKu_Lk
 » 9 days ago, # |   0 When do we get registered the contest in our profile?
 » 9 days ago, # |   +1 Is anyone here who solved F using Binary or ternary search?
•  » » 9 days ago, # ^ |   +2 yeah, using lower bound and upper bound Solution Link
•  » » » 9 days ago, # ^ | ← Rev. 2 →   0 I liked your approach, not sure if it's really binary search. Actually, I was expecting something similar to this: Codearray=[] def calculate(c): global array temp=0 counter=1 for i in range(1,len(array)): if array[i]!=array[i-1]: if counterc: temp+=counter-c counter = 1 else: counter+=1 if counterc: temp+=counter-c return temp def ternary_search(l,r): global ans mid1=l+(r-l)//3 mid2 = r-(r-l)//3 if mid1==l: for i in range(l,r+1): y=calculate(i) if y
 » 9 days ago, # |   +13 To not keep you waiting, the ratings updated preliminarily. In a few hours, I will remove cheaters and update the ratings again!
•  » » 9 days ago, # ^ |   0 Professor
•  » » 8 days ago, # ^ | ← Rev. 2 →   0 My handle is RohitS.Singh . I did not know that submitting same code from multiple accounts is not accepted , also I am a newbie so just wanted to check my solution before submitting through my main account. I was unaware of rules so created another account whose handle is dar_k_horse and submitted the solution there before submitting through my main handle. I recently got a mail from codeforces about the same . I accept my mistake and as I am now aware of the rules would never repeat the same . I am not a cheater.
 » 9 days ago, # |   +2 Why unordered map gets tle in F?
•  » » 9 days ago, # ^ | ← Rev. 2 →   +4 Because of anti-hash test. In these kind of tests unordered_map takes it's worst case complexity of O(n). You can check this blog on unordered_map.
•  » » » 9 days ago, # ^ |   0 Thanks a lot for sharing this, TIL. I was completely stumped as to why unordered map didn't work!
 » 9 days ago, # |   0 problem (C + D) link : https://www.youtube.com/watch?v=3_qtawn7zHY problem(A + B) link : https://www.youtube.com/watch?v=J3u3UAUHrjo
 » 9 days ago, # |   0 How to approach problem F if instead of "either zero or C times" we consider "multiple of C times" in the problem statement? (I misread it during the contest).
•  » » 9 days ago, # ^ |   +4 You can take frequency of frequency of elements as count. Each time just check whether number of elements of that particular frequency * frequency of frequency of elements is max.
•  » » » 9 days ago, # ^ |   0 I am not sure if you understood what i asked. Or can you please elaborate your approach as to how is this possible without modulo arithmetics by just using frequencies.
•  » » » » 9 days ago, # ^ |   0 F solution. I hope my solution is much clearer. I have just used 2 maps to store frequency of elements and frequency of frequency. The product of this is the number of elements we can have include in our array.
•  » » » » » 9 days ago, # ^ |   0 I asked how to solve an alternate version of F viz. "how to solve if we can take all frequencies in a multiple of C times instead of just C times or 0 times", not this! Leave it. Thanks.
 » 9 days ago, # | ← Rev. 5 →   +4 My F got accepted in 100 ms but 2000 ms after hacking phase. Collision between values is the reason for this because of hash function?
•  » » 9 days ago, # ^ |   +1 Yeah sucks, same here.The one with unordered_map fails but with map.I purposefully used unordered_map thought it would be faster.
 » 9 days ago, # |   +1 good contest
 » 9 days ago, # |   0 My handle is RohitS.Singh . I did not know that submitting same code from multiple accounts is not accepted , also I am a newbie so just wanted to check my solution before submitting through my main account. I was unaware of rules so created another account whose handle is dar_k_horse and submitted the solution there before submitting through my main handle. I recently got a mail from codeforces about the same . I accept my mistake and as I am now aware of the rules would never repeat the same .
 » 8 days ago, # | ← Rev. 2 →   0 Problem F — Equalize the Array"you can consider only unique values of C (there are no more than O(n*√n)), and get a solution in O(n*√n)"I used this approach mentioned in the editorial during the contest and get a TLE in test case 12.Here is my submission:107609642
 » 8 days ago, # |   0 Rating got changed again ? Something happened?
 » 8 days ago, # |   0 As for my ranking in this contest,when I found my name in the "common standings",it shows that I got rk1947,but when I chose "Friends standings",I got rk2130,and finally the increase of my ratings is based on the rk2130......Though I'm not so focused on the ratings itself,I wondered how this happened. :D
 » 8 days ago, # |   0
 » 8 days ago, # | ← Rev. 2 →   0 Hi, Guys! I am stucked on #F on 12 test with time limit. No ideas to fix it. May u help, please? int t; cin >> t; while (t--) { ll n; cin >> n; vector a(n); unordered_map m; for (auto& x : a) { cin >> x; ++m[x]; } vector cnts; ll sum = 0; ll cnts_size = 0; for (auto x : m) { cnts.push_back(x.second); sum += x.second; ++cnts_size; } //countSort(cnts); sort(cnts.begin(), cnts.end()); ll c_val = sum - cnts_size *cnts[0]; for (ll i = 1; i < cnts_size; ++i) { if (cnts[i] == cnts[i - 1]) continue; ll val = sum - (cnts_size - i) * cnts[i]; c_val = min(val, c_val); } cout << c_val << endl; } 
•  » » 8 days ago, # ^ |   0 There is a test makes your unordered map collisions.
•  » » » 7 days ago, # ^ |   0 Tnx!
 » 6 days ago, # |   0 Why were solutions rejudged on uphacks?