### chokudai's blog

By chokudai, history, 4 years ago, We will hold AtCoder Beginner Contest 140.

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

We are looking forward to your participation! Comments (35)
| Write comment?
 » 4 years ago, # | ← Rev. 2 →   .
•  » » fixed!
 » Auto comment: topic has been updated by chokudai (previous revision, new revision, compare).
 » 4 years ago, # | ← Rev. 2 →   How to solve E?D — Let a be the number happy people initially, answer would be min(n-1, a+2*k) because at every step you increase at most 2 happy people.F — Just simulate the process greedily. Start with the maximum produce the second maximum with it then 3rd and 4th maximum using 1st and 2nd respectively. At any step, if it is not possible to then answer is No else Yes. Submission
•  » » Can you explain sample test case 3 of problem D?
•  » » » Just flip the RRRRR block so the result is all LLLLLLLLLL.
•  » » » You can take L = 6, R = 10. The string will become LLLLLLLLLL
•  » » To solve E you can iterate all the i that in some array the second largest is i
•  » » » if i appear at is[i] you need to find the nearest j that bigger than i in the left and second nearest k in the left also the nearest and the second nearest in the right
•  » » » » And I use set::lower_bound to do this
•  » » » » You can read my solution by searching handle:Gary in the contest
•  » » For F, I used the same thing you said: simulated the process using priority_queue but got WA. Here's my submission: Submission
•  » » 4 years ago, # ^ | ← Rev. 4 →   For every element $x$ ,try to calculate $t(x)$ ,the number of intervals which $X_{L,R}=x$ .The answer is $\sum_{x=1}^n x\cdot t(x)$ .If $a_p=x$ ,let $pre1$ be the largest $i$ that $1\le ia_p$ ,and $pre2$ be the second largest $i$ .Let $suf1$ be the smallest $i$ that $pa_p$ ,and $suf2$ be the second smallest $i$ .Then $t(x)=(pre1-pre2)\cdot (suf1-i)+(suf2-suf1)\cdot (i-pre1)$ .
•  » » » Can you share the code?
•  » » » » Here's my submission.
•  » » » » » Which technique did you use in this problem?
•  » » » » » » Binary search and segment tree.
•  » » » » » » » It's out of my knowledge, I will update soon =))
•  » » » too good! but i had problem in implementation when pre2 doesnt exist. can you help me with it ?
•  » » » » Well,as you can notice in my code, $pre1-pre2$ means we that can choose $pre2 •  » » » » » Thanks alot! •  » » » May I ask what is the complexity of this solution? If you do this for all n, each of which results in a linear scan, would the solution be quadratic? Thank you so much! •  » » » » I use binary search and segment tree to calc them.My code.The complexity of the solution is$O(n\log^2 n)\$ .I guess there's a linear approach,but I haven't got it yet.
 » problem D, why the output in the sample input #4 is 7 instead of 6, thanks in advance
•  » » If you consider one based indexing then change the 4th indexed 'L' and 6th indexed 'L' then the string will be RRRRRRRLL and number of happy people will be 7.
•  » » You swap the two left L into R, then result is RRRRRRRLL, whichs value is 7.
 » I found some problems harder to understand than usual.Needed like 30 minutes to get the fact that L turn to R and vice versa in D, not just the possitions swap.I understood the way of reproduction in F after the contest, not within.
 » Geothermal's Solutions https://codeforces.com/blog/entry/69629
 » A solution — Just need to print n*n*n B solution — https://atcoder.jp/contests/abc140/submissions/7385892 . C solution — https://atcoder.jp/contests/abc140/submissions/7390408 . D solution — https://atcoder.jp/contests/abc140/submissions/7399771 .
•  » » All solutions by me. If any doubt in any of these do comment
 » What's wrong in this submission for F?
 » Problem F:why I get WA on test_69 and test_71 in this submission?Could someone help me?
 » 4 years ago, # | ← Rev. 2 →   When would be editorial published for English readers? And also where is the link of English editorial provided?
•  » »