Блог пользователя cry

Автор cry, 6 дней назад, По-английски

Thanks for participating! Despite the round being unrated, we hope you've enjoyed the problemset. We put a lot of effort into this round :prayge:

I want to give huge thanks to Dominater069 and satyam343 for their heavy contributions to the subtasks of G. If you're participating out of competition, we hope you enjoyed attempting these bonus subtasks. Otherwise, we hope you will enjoy upsolving them!

2009A - Minimize!

Problem Credits: cry
Analysis: cry

Solution

2009B - osu!mania

Problem Credits: cry
Analysis: cry

Solution

2009C - The Legend of Freya the Frog

Problem Credits: vgoofficial
Analysis: cry

Solution

2009D - Satyam and Counting

Problem Credits: vgoofficial
Analysis: cry

Solution

2009E - Klee's SUPER DUPER LARGE Array!!!

Problem Credits: cry
Analysis: cry

Solution

2009F - Firefly's Queries

Problem Credits: cry
Analysis: cry

Solution

2009G1 - Yunli's Subarray Queries (easy version)

Problem Credits: cry, vgoofficial
Analysis: vgoofficial

Solution

2009G2 - Yunli's Subarray Queries (hard version)

Analysis: Solution 1: vgoofficial, Solution 2: awesomeguy856

Prologue
Solution 1 (Lazy Segment Tree, Offline)
Solution 2 (Binary Lifting, Online)

2009G3 - Yunli's Subarray Queries (extreme version)

Analysis: Dominater069

Solution
Разбор задач Codeforces Round 971 (Div. 4)
  • Проголосовать: нравится
  • +83
  • Проголосовать: не нравится

»
5 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by cry (previous revision, new revision, compare).

»
5 часов назад, # |
Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

The G2 problem can also be solved by the MO algorithm. My solution is:https://mirror.codeforces.com/contest/2009/submission/279633321

»
5 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

binary search forces

»
5 часов назад, # |
  Проголосовать: нравится +25 Проголосовать: не нравится

Nice Div. 3 contest !

»
5 часов назад, # |
Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

In problem E i used prefix sum and got MLE bruh...

»
5 часов назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

Can we solve D faster than O(n^2) if xi's were real numbers instead of integers ?

  • »
    »
    5 часов назад, # ^ |
    Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится

    It appears I am wrong. Disregard this

    • »
      »
      »
      5 часов назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      actually, no i think there are other cases,

      Spoiler
»
5 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

In the C problem, there is a neat way to check whether there will be any other case or not.

Following the given explanation, one can see, that if any of the points on the side which contributes 2 points to the triangle are moved, the angle increases, and since we can't get them any closer without falling into Case 1, we can't have any more cases.

Another way that can be used is the fact that the slopes of the two perpendicular lines must give a product of -1.

So, if the points were $$$(x_{1}, 0), (x_{2}, 1), (x_{3}, 0)$$$, then we would have :

$$$(\frac{x_{2} - x_{1}}{1 - 0}) * (\frac{x_{3} - x_{2}}{0 - 1}) = -1$$$

which leads to :

$$$(x_{2} - x_{1})(x_{3} - x_{2}) = 1$$$

And since the differences will always be integers, we have :

$$$x_{1} + 1 = x_{2} = x_{3} - 1$$$

  • »
    »
    4 часа назад, # ^ |
    Rev. 5   Проголосовать: нравится 0 Проголосовать: не нравится

    It's a good explanation for showing there is no other cases. I came up with similar idea using geometric properties of the median in a right triangle. Other than triangles with sides in a vertical line $$$(x, 0), (x, 1)$$$, triangles must have sides on a horizontal line. Then the median of the right triangle separate out the two parts $$$(x - t, k) ,(x + t, k)$$$ with the last vertex is $$$(x, k'), k,k'\in \{0,1\}$$$. Then the median of length m calculated as $$$m^2 = 1^2 + t^2\ $$$, thus $$$(m - t)(m + t) = 1$$$, with similar argument $$$m$$$ must be 1. Sides on horizontal line is 2, then $$$t = 1$$$

»
5 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

~~~~~~

if(x > y){
    cout << 2* ceil(1.0 * x/k) - (ceil(1.0 * x/k) >= ceil( 1.0 * y/k)) << endl;
    continue;
}

else {
    cout << 2 *ceil(1.0*  y/k)<< endl;
    continue;
}

~~~~~

why this fails??

»
5 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I'm really happy to unrate b/c I'm really mad because I don't submit my code. :)))))

»
5 часов назад, # |
  Проголосовать: нравится +46 Проголосовать: не нравится

G2 and G3 are not div4 problems. They should only appear in div2 or div1.

  • »
    »
    5 часов назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    On the contrary, they cannot appear in div2 or div1

    They are far too standard for both of them.

    They were never meant to be solved by actual participants, A — G1 is the actual div4 round. They are meant to educate higher rated people.

    • »
      »
      »
      5 часов назад, # ^ |
        Проголосовать: нравится +6 Проголосовать: не нравится

      so why have div 4 :/

      • »
        »
        »
        »
        4 часа назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        wdym? why have these "bonus" tasks in div4? or why have div4 at all?

        why have these "bonus" tasks in div4?

        how does it hurt you? Ignore it if you want to. It is not fit for a div2 or div1 clearly, why not have it here incase someone finds it useful?

        why have div4 at all?

        Because we have an abundance of easy tasks and an abundance of low rated people? D

    • »
      »
      »
      5 часов назад, # ^ |
      Rev. 2   Проголосовать: нравится +4 Проголосовать: не нравится

      clearly not div4, admit your mistake instead of making baseless points.

      Dominater069 orz thanks for admitting it

      • »
        »
        »
        »
        4 часа назад, # ^ |
        Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится

        They were never meant to be solved by actual participants

        i admitted it lol.

        Not every task exists has to exist for intended participants.

        Authors (and me) wanted to add bonus educational tasks for high rated participants. I really dont understand how the intended audience was affected

        • »
          »
          »
          »
          »
          3 часа назад, # ^ |
            Проголосовать: нравится +19 Проголосовать: не нравится

          I appreciate the extra tasks. G2 is fairly new to me, and G3 was totally new to me. These were good tasks for learning.

    • »
      »
      »
      3 часа назад, # ^ |
        Проголосовать: нравится +7 Проголосовать: не нравится

      Why Div.4 have to educate Master or Grandmaster? I cannot understand.

      I think that that an overwhelmingly difficult problem is standard so can't put it in Div.2 doesn't mean that it can plugged in Div.4. I want a good problem must to be placed where a more people can solve it.

      • »
        »
        »
        »
        3 часа назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Why Div.4 have to educate Master or Grandmaster?

        It doesnt have to, but isnt it good if it does? Who did it harm smh? Experts who want to be able to AK every div4 round. welp sad for them

        Authors tried to do a nice thing by including extra tasks (something which they didnt have to do and still would be paid the same)

        I want a good problem must to be placed where a more people can solve it.

        except G3 or G2 aren't good problems. Educational? sure. But educational problems should not affect rating.

        • »
          »
          »
          »
          »
          3 часа назад, # ^ |
            Проголосовать: нравится +7 Проголосовать: не нравится

          I hate you so much

        • »
          »
          »
          »
          »
          3 часа назад, # ^ |
          Rev. 3   Проголосовать: нравится +7 Проголосовать: не нравится

          I think it's more like "it could've benefited more people in a higher division" rather than "it harmed those people."

          While I see your argument, and it may be true that it won't be very good to be in a Div. 1 round, I honestly don't think there would be many solves even if it was in a Div. 2. I agree that standard problems shouldn't heavily affect ratings, but I think the benefits are far bigger to have this problem in a Div. 2 round instead of a Div. 4 round.

          See how many of the 'target' people for these problems have actually participated in this round. If you want to attract those 'target' people and educate them, it needs to be rated for them to be motivated. Candidate masters won't expect a Div. 4 round to actually educate them, so there is little reason for them to even register for the contest and read the problem. It's not like having a few official solves ruins the whole authority of the rating system. It's way more important to motivate the fitting people to read and try the problem.

          Also, G2 was actually an interesting problem for me. It may involve only a few standard techniques, but I don't think such standardness necessarily made the problem bad.

          • »
            »
            »
            »
            »
            »
            3 часа назад, # ^ |
            Rev. 2   Проголосовать: нравится -10 Проголосовать: не нравится

            i agree with you that it would be on the edge of being fine for div2 because its hard enough so affecting only small number of people

            But

            • you cant easily port a problem in between rounds, or decide the division based on one problem

            • even if it doesnt affect much, i dont see many div2 coordinators who would accept G3 as a d2F (even though it would be somewhat fine imo)

            • there was a high likelihood that G3 existed on the internet since it is a very natural problem, and indeed it's max variant existed on hackerrank. https://www.hackerrank.com/challenges/little-alexey-and-sum-of-maximums/problem (somebody solved it using this too)

        • »
          »
          »
          »
          »
          3 часа назад, # ^ |
            Проголосовать: нравится +8 Проголосовать: не нравится

          Oh, you think G2 and G3 aren't good problems... Then why they are in contest? Isn't it wierd? Is it OK that not good problems in Div.4?

          But educational problems should not affect rating.

          Then why Educational CodeForces (Div.2) exists? Just do plug all Educational CodeForces problem in Div.3 or Div.4. But there is reason that Educational CodeForces exists.

          And why you're saying like that? Nobody said "I want to solve all of them!"

          I'm just saying that problem must be its suitable position, so it can teach more people. If you do not think so, then I'm sorry. But I believe every problemsetter and coordinator, tester knows that Div.4 is not for Master or Grandmaster, but for Newbie or Pupil.

          • »
            »
            »
            »
            »
            »
            3 часа назад, # ^ |
              Проголосовать: нравится +5 Проголосовать: не нравится

            you think G2 and G3 aren't good problems

            From problem solving perspective, it is mostly standard and implementation for me.

            From eudcational perspective, it is useful as a problem to teach you the power of sweepline algorithms. There can be educational value in a problem despite it not being a "good" problem.

            Then why Educational CodeForces (Div.2) exists?

            It's fake educational and has been for a long time.

            years before, it used to be unrated and containing actually standard tasks. Now, it's just slightly more standard than average div2, but the name stuck.

            This change happened almost solely because they became rated rounds.

            I'm just saying that problem must be its suitable position, so it can teach more people

            But it comes at the cost of affecting people's ratings. Who likes to lose rating to a standard problem? I certainly don't

    • »
      »
      »
      43 минуты назад, # ^ |
        Проголосовать: нравится +1 Проголосовать: не нравится

      Without a doubt, this problem cannot appear on Div1, but it is actually fine as Div2F (we definitely had worse and more standard d2F).

      The following only applies to unofficial contestants:

      the mild complaint I had is that I participated in a div 4 round, expecting div 4 difficulties and “div 4 level resistances” only to find that this is not the case. Div 4 to me had been a “quick and easy AK and funny internet speed test with no verdicts for 10 minutes and so every penalty is worth 25 or more”. In fact, div2/3/4 (and obviously also div1) have distinct feels to it, so I am not so sure in general making it feels like div2, which is what happened when G2 and G3 we’re included.

      This only made sense under my belief that this problem can totally be used on D2F as is.

  • »
    »
    4 часа назад, # ^ |
      Проголосовать: нравится +10 Проголосовать: не нравится

    I can see G2 barely being on the edge of a Div. 3 but G3 is straightforward way too difficult. It's maybe a harder one even for a 2F.

    • »
      »
      »
      4 часа назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      G3 is definitely below d2F level

      • »
        »
        »
        »
        4 часа назад, # ^ |
          Проголосовать: нравится +3 Проголосовать: не нравится

        I think it's more like most of the other 2Fs are too difficult in general, but okay.

        • »
          »
          »
          »
          »
          4 часа назад, # ^ |
            Проголосовать: нравится 0 Проголосовать: не нравится

          if most 2F are more difficult then that’s the 2F difficulty level lmao

          • »
            »
            »
            »
            »
            »
            4 часа назад, # ^ |
            Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

            You can say the same thing to this: if we keep having these kind of problems in 4G, then this becomes a 4G level problem. However, that would be far from what I'd expect from a 4G, and 2F is kind of such state already.

            • »
              »
              »
              »
              »
              »
              »
              4 часа назад, # ^ |
                Проголосовать: нравится 0 Проголосовать: не нравится

              I agree that G2/3 are beyond div 4 level but I think it’s clear that they’re not intended to be solved by div 4 participants

              • »
                »
                »
                »
                »
                »
                »
                »
                3 часа назад, # ^ |
                  Проголосовать: нравится +11 Проголосовать: не нравится

                But they are in a DIV4 contest

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  3 часа назад, # ^ |
                    Проголосовать: нравится +3 Проголосовать: не нравится

                  It's an extra problem to be upsolved for education value. What harm did putting these questions here do? Did it affect anyone? No. Only 1 trusted user solved G2 and G3.

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  3 часа назад, # ^ |
                    Проголосовать: нравится 0 Проголосовать: не нравится

                  Maybe my opinion is stupid but when you say a DIV4 contest, I expect a contest that contains problems that a DIV4 participant can solve or upsolve. Similar logic for other divisions. But it is fine. Feel free to put a Div1F in the next DIV4 contest.

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  3 часа назад, # ^ |
                    Проголосовать: нравится +11 Проголосовать: не нравится

                  How many people in division 2 can solve F you think? What about the old div 4 G about 2-sat? Do you think newbies and pupils have a chance of inventing that on the fly without seeing 2sat before? Almost every final question on each round is far too hard for its division. We only included G2 and G3 because they follow quite naturally from G1, and if is impossible to port questions between rounds.

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  3 часа назад, # ^ |
                    Проголосовать: нравится 0 Проголосовать: не нравится

                  I never said the past div4 rounds were perfect. Also, I said I expect the target participants to be able to SOLVE or UPSOLVE the problems. So, because every final question on each round is too hard for its division, every round should follow this pattern? Anyway, it is your round, do as you want.

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  2 часа назад, # ^ |
                    Проголосовать: нравится +4 Проголосовать: не нравится

                  "Also, I said I expect the target participants to be able to SOLVE or UPSOLVE the problems."

                  Ok? isn't that the purpose of G2 and G3? For div.4 participants to upsolve? Of course, you don't have to upsolve it right now. You can always come back when you're better. The problem doesn't disappear.

                  I don't see any harm in contests with a harder final problem than its intended division. It gives strong participants of the intended division something to think about for the rest of the contest (instead of doing nothing), and makes more of a competition for higher rated participants.

»
5 часов назад, # |
  Проголосовать: нравится +26 Проголосовать: не нравится

Sharing my video of winning the round along with explanations of my solutions: https://www.youtube.com/watch?v=JhL-oPzptlI

»
5 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

E was great !

»
5 часов назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

I tried solving E by interpreting it as a function and using the quadratic equation, but it keeps giving the wrong answer for n = 1000000000, k = 1000000000

typedef int64_t ll;
ll n, k, sk;
cin >> n >> k;

sk = gauss(k - 1); // starting k : the gauss sum of the numbers before the start of the series

ll max = gauss(k + n - 1) - sk;

// quadratic equation

// pref = gauss(n) - sk
// pref = (n^2 + n)/2 - sk
// where does 2pref intersect max? (because we want pref = max-pref)
// n^2 + n - 2*sk = max
// n^2 + n - (2*sk + max) = 0

// a = 1, b = 1, c = -(2*sk+max)

// delta = 1 ^ 2 - 4 * -(sk+max)
// delta = 1 + 4 * (2*sk + max)

ll delta = 1 + 4 * (2*sk + max);

// x1,2 = (-b +- sqrt(delta))/2*a
//	= (-1 +- sqrt(1 + 4 * (2 * sk+max)))/2 

ll x1 = round((-1 + sqrt(delta)) / 2);
ll x2 = round((-1 - sqrt(delta)) / 2);

ll x = min(abs(x1), abs(x2));

ll ans = 2 * (gauss(x) - sk) - max;
cout << abs(ans) << '\n';
  • »
    »
    5 часов назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    I also used the same logic. You probably have to use unsigned long long. I was able to pass the cases using that.

    • »
      »
      »
      4 часа назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      But wouldn't a <= sqrt(D). so, a — sqrt(D) will never be a solution since it is negative why are u checking it ??

  • »
    »
    4 часа назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    was stuck in that for some time, but then used unsigned long long and it worked.. But came to the comments to see that it can be done by using binary search, need to see how they are applying it to the V curve, i mean ternary can work but binary.. no intuition honestly

»
5 часов назад, # |
Rev. 3   Проголосовать: нравится +2 Проголосовать: не нравится

For G1: There's a mathematical logic behind "ai — i". Let's say we have a sequence "(C, C + 1, C + 2, C + 3 + ...)". Any 'ith' element ai will be equal to "C + i — L", where 'L' is the starting index of the window. So (ai = C + i — L) => (C — L = ai — i). This (C — L) is a static part, which means we have to find the maximum occuring "ai — i".

»
5 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

You can think of E as an inverted mountain array and look for the minimum point using binary search

»
5 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I think G1 can be solved by finding the longest increasing subarray for each query in O(logN)

Ans will be (right — left + 1) — longest;

»
4 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

My solution 279640569 of F, is giving correct output as 13 on my local and online compilers but wrong answer as 12 on codeforce's judge for following test case:

1

5 1

4 8 3 2 4

7 10

Can someone explain it?

»
4 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

dit con me codeforces lam gan het thoi gian moi bao deo cong rating, dung la cf rac

»
4 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится
import java.util.*;
 
public class one {
    public static void main(String[] args) {
        java.util.Scanner sc = new java.util.Scanner(System.in);
 
        int t = sc.nextInt();
 
        for (int i = 0; i < t; i++) {
            long x = sc.nextLong();
            long y = sc.nextLong();
            long k = sc.nextLong();
            
            long jumpsX = (x + k - 1) / k; 
            long jumpsY = (y + k - 1) / k; 
 
            long moves = Math.max(jumpsX, jumpsY) * 2 ;
 
           
            if (x>y) {
                moves--;
            }
 
            System.out.println(moves);
        }
        sc.close();
    }
}

why wasnt this AC for the frog and freya question?

»
4 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

can somebody explain how they used binary search for E? i found the function to be unimodal and hence i applied ternary search to find the point of minima, i dont get the intuition for binary search (i dont see monotonicity)

  • »
    »
    4 часа назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    There is a V formation, check my solution. To find minima just use formula of summation n there are different cases where mid will lie

  • »
    »
    4 часа назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Just look for the point where current_sum > (total_sum)/2. The correct answer is nearby there. .

»
4 часа назад, # |
Rev. 2   Проголосовать: нравится +6 Проголосовать: не нравится

The entire universe is against me for becoming pupil. Was doin super well today until that announcement appeared, L cry, L servers... MikeMirzayanov I think its time to add a new god damm server.

»
4 часа назад, # |
Rev. 2   Проголосовать: нравится +14 Проголосовать: не нравится

I miss SlavicG,mesanu,flamestorm ... (╥﹏╥)

»
4 часа назад, # |
Rev. 4   Проголосовать: нравится 0 Проголосовать: не нравится

Here is a clean(er than the edi) solution to C and a unique solution to D.

For C we can see that

Spoiler

As for D, which I found much more interesting, though do note I misread it and as such overcomplicated it.

Spoiler

Here are submissions for both, hope that puts these problems into a bit of a different perspective! C: 279561294 D: 279622363

This contest had quite a few issues with the queue and pages loading, however I still enjoyed the problems and I hope you did too! I would have gotten plus VE if this contest was rated however instead of complaining I had fun solving these problems even if I did overcomplicate D a bit, however it would give insight to a possible harder version of the problem if it was not only 0 and 1 on the Y.

»
4 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

G题太难啦。写了个 BZOJ4262 的做法才过。

»
4 часа назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

This was a good round, sad that it got unrated.

»
4 часа назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

thanks for writing, issues not your fault!

»
4 часа назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

I have a different solution for G2. Use a set and a map to get the minimum moves for the window of size k starting from every index. Then use a stack to build a vector to store the index of next smaller number. Then use jumps to next smaller number to compute answer for every range.

Code
»
4 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Nice Div3 Contest !!!

»
4 часа назад, # |
Rev. 9   Проголосовать: нравится 0 Проголосовать: не нравится

My code is failing in case of- 1000000 100000 10 givng me answer- 200000 !! Can someone point the mistake ?? Thanks

#include<bits/stdc++.h> 
using namespace std;
int main(){ 
   long t; cin>>t; 
   for(long i=0;i<t;i++){ 
      long long x,y,k; 
      long count=0; 
      cin>>x>>y>>k; 
      while(x>0 || y>0){ 
         int result_x=min(x,k);
         x-=result_x; 
         int result_y=min(y,k); 
         y-=result_y; 
          count+=2;
        } 
        cout<<count<<endl; 
    } 
    return 0;
}
»
3 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I loved the HSR and Genshin references. Please do continue naming problems on our favourite characters. Thank you!

»
3 часа назад, # |
Rev. 4   Проголосовать: нравится 0 Проголосовать: не нравится

I have implemented the same logic as the solution above for 2009D - Satyam and Counting, but keep getting

Wrong answer on test 2: wrong answer 7th numbers differ - expected: '100', found: '99'

I cannot see the corresponding input.

Can anyone please tell me what I am missing? https://mirror.codeforces.com/contest/2009/submission/279654100

  • »
    »
    3 часа назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    I spotted one mistake but that does not fix the Wrong Answer above. The mistake is that each array should have size n+1 instead of n because each 0 <= x <= n. I also fixed the ranges accordingly. But, as mentioned, the Wrong Answer stays the same.

  • »
    »
    3 часа назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    I figured it out. Because of my confusion with the range of x, the code decrements x. That maps x=0 to x=-1, which does not result in an error but in undesired behavior when used as a list index.

»
3 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

We can use binary search to search for the greatest i such that a1+⋯+ai≥ai+1+⋯+an

Isn't the solution for E wrong? If the above statement is the correct solution, the greatest i is just len-1 no?

»
3 часа назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

In problem E's editorial ...

We can use binary search to search for the greatest i such that a1 + ⋯ + ai ≥ ai+1 + ⋯ + an . Note that here, the positive difference is minimized. If we move to i+1 , then the negative difference is minimized (since the sum of prefix will now be less than the sum of suffix). The answer is the minimum absolute value of both cases.

It should be a1 + ⋯ + ai ≤ ai+1 + ⋯ + an because we want to minimize the difference.

cry
(ignore the formatting)

»
3 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Can't understood editorial solution for G2

»
2 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

G2 can also be solved using sqrt decomposition in $$$O(Q*N/B*log(B))$$$ where $$$B=\sqrt{N}$$$.

For each query, maintain the answer from left to right. If the current minimum is greater than the current block's minimum, we can use a binary search to find where the current block's first minimum is.

Submission: 279662760

»
2 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Can we use ternary search at the problem E, though we need to find the minimum here?

»
102 минуты назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

anyone mind to explain solutions of G3?

  • »
    »
    68 минут назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    i wrote a really long solution as you can see above in the editorial :(

    Any specific queries in it?

»
34 минуты назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

Can someone suggest a testcase where this will fail for C? It fails on testcase 2.

wrong answer 862nd numbers differ — expected: '2', found: '1'

Spoiler
  • »
    »
    18 минут назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Cannot compare x and y. You should compare ceil(x/k) and ceil(y/k) instead.

    Countercase: x=9, y=8, k=3. Your solution prints 5 but correct answer is 6