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

Автор 300iq, 4 года назад, По-английски
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Разбор задач Good Bye 2021: 2022 is NEAR
  • Проголосовать: нравится
  • +124
  • Проголосовать: не нравится

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

Problem solved

how
»
4 года назад, скрыть # |
Rev. 2  
Проголосовать: нравится -21 Проголосовать: не нравится

.

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

    The equation in the problem statement is an Arithmetic progression. So, all the elements of the array should be in a series.

    To go about it, we iterate over every i and j, and find the common difference of the series fixing the values in those two positions, which is a[j]-a[i]/j-i and fill the array with this progression (like ..,a[i]-d,a[i],a[i]+d,a[i]+2d,....,a[j],..)and check the number of elements that do not match with the original array.

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

      I did in the same approach but I am getting wrong answer on test case 7, Please tell me what's wrong with my code.This is my code

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

        The WA was because comparing double values using == doesn't always give the right output due to the precision error in rounding up those decimals.

        So, what i did was storing the difference in a variable and checking if it is lesser than a small value epsilon for comparision.

        I've used code you've put, with this modification and it got AC. here.

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

        I think I shouldn't use double or may be the precision while converting it into integer causing me trouble(I still don't know). But I used a new approach same as shanks said and This is my new code

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

          Can you please explain this code

            int d=v[j]-v[i],r=j-i;
                      int g=gcd(d,r);
                      g=abs(g);
                      d/=g;
                      r/=g;
          

          in your code.

          What it means and why you used?

          Thanks in advance

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

            It is to get the minimum integer difference between the minimum range of elements. To explain it clearly->

            For every pair of elements i and j (where 1<=i<j<=n) I am setting d(difference) as d=a[j]-a[i]; To get difference between consecutive elements we should divide it with difference of their range=> j-i; so d becomes d=(a[j]-a[i])/(j-i); since this value gives us real number and definitely know that the array contains only integers, I used gcd g=gcd(d,j-i) so that when I divide both a[j]-a[i] and j-i with its gcd I will get integers. Finally we can say that for every (j-i)/g the difference between the A.P(arthematic progression) elements is (a[j]-a[i])/g. I hope you understand this, if you have any doubts please comment down below and (Prerequesite Arthematic progression is must to understand what i said above)

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

              I am just adding an example:

              One of the test cases: 1 1 2 2

              the difference between 1st(i=1) and 3rd(j=3) element is 1(a[i]=1) and 2(a[j]=2). d=(a[j]-a[i])/(j-i) => d=(2-1)/(3-1)==>0.5; and the sequence becomes 1, 1.5, 2, 2.5 But we already know that array only has integers and to skip those real values and dividing both numerator and denominator with their gcd: i.e gcd of 1,2 is 1(in this case)=> for every 2 elements the difference is 1(numerator is difference d and denominator is number of elements)

              ===> my sequence is 1 — 2 — where (- is a real value) therefore I need to change 2 elements to get the required sequence.

              Let's look at another example: 2 5 4 5 6 100 50 9 10 and i=1, j=3 , a[i]=2, a[j]=4:: a[j]-a[i]=2 j-i=2 gcd g=2; ==> 2/2==> (2/2)/(2/2)==> 1/1 for every element the difference is 1: and therefore my required sequence is::: 2 3 4 5 6 7 8 9 10 and I should change 3 elements to get my required sequence. I hope you understand now and if you have any doubts please comment down.

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

      What is the time complexity of that?

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

    There is no detail. Two observations.

    The formula given in the problem statement corresponds to an AP. (you can prove it easily)

    1. You can choose 1 element and make the rest equal to it. n — 1 operations.
    2. You choose any two elements to remain the same and now that u have done that your upper bound to answer is n — 2. From 2.

    Since you took the effort of fixing two elements in the sequence i.e you can form your AP out of it and check if other elements match with the corresponding AP.

    (Yes very magical observation since it is necessary and sufficient for our needs)

    So just pick any two elements and keep forming APs take minimum over all of them.

    P.S :- Some people have their solutions passed using doubles which isn't technically correct so when you fix your difference for the AP use methods which avoid doubles.

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

For problem C, isn't the upper bound of the answer always n — 2 and not n — 1, since we can always pick two elements to make an AP and then check how many elements we have to change?

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

could someone explain D in more detail.

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

can anybody help me pls in "B"problem I have two codes for the problem out of them one is accepted and another is getting TLE . can anybody let me know why this is happening.

link1-TLE: https://mirror.codeforces.com/contest/1616/submission/141148880 Link2-AC: https://mirror.codeforces.com/contest/1616/submission/141149035

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

what's wrong with my code ? please help my submission : problem C thanks in advance

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

Could someone explain 1616F - Tricolor Triangles in a little bit more detail?

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

Brute force with random can passed...

there are many limitations, and we just choose 1000 of them randomly and it got accepted...

141155530

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

Can someone tell me is this contest was unrated as I participated and its showing this contest name under unrated and still my rating didn't updated too kindly guide me .

»
4 года назад, скрыть # |
Rev. 7  
Проголосовать: нравится +40 Проголосовать: не нравится

In problem E, for some reason during the contest I thought it would be very complex to maintain the shifts using a BIT. So here is another way I used to solve this problem without any data structures (albeit with trickier implementation).

Similar to the editorial we realize that the optimal answer will be of the form $$$s_i = t_i$$$ for all $$$i \lt k$$$ and $$$s_k \lt t_k$$$ for some $$$1 \leq k \leq n$$$.

Let us suppose $$$t_1 = t_2 = \ldots = t_x$$$ and $$$t_x \ne t_{x + 1}$$$. We have two cases for this block:

  1. The smaller position $$$k$$$ will be in this block.

    • We want to make $$$s_1 = s_2 = \ldots = s_{y - 1} = t_1$$$ and $$$s_y \lt t_1$$$ for some $$$y \leq x$$$.
    • For each possible $$$1 \leq y \leq x$$$, we could fix the first $$$y - 1$$$ occurrences of $$$t_1$$$ and then move the first occurrence of a character less than $$$t_1$$$ to $$$y$$$, and take the min over these subcases.
    • However since we need to remove the first $$$y$$$ occurrences of $$$t_1$$$ from $$$s$$$ so we can find the actual distance of the closest character less than $$$t_1$$$ after moving them, we use upto $$$O(n)$$$ time for each $$$y$$$, this could become $$$O(n ^ 2)$$$ overall for a large block, so this wont work.
    • If you write out and compare the equations for various $$$y$$$, we can notice that there is always an optimal $$$y = z$$$. This is just the smallest $$$z \leq x$$$ such that $$$s_z \ne t_1$$$ before we perform any moves. (or $$$x$$$ if there is no such position)
    • So with this optimal $$$y = z$$$, $$$ans = min(ans, cost + (\text{first_smaller} - z))$$$, where $$$cost$$$ is the cost for previous blocks and $$$\text{first_smaller}$$$ is the first index such that $$$s_{\text{first_smaller}} \lt t_1$$$
  2. The smaller element will be in a later block.

    • We want to make $$$s_1 = s_2 = \ldots = s_x = t_1$$$.
    • Let the first $$$x$$$ positions of $$$t_1$$$ in $$$s$$$ be $$$pos_1, pos_2, \ldots, pos_x$$$, then the min cost of making it equal is $$$\sum_{i = 1}^{x} {pos_i - i}$$$.
    • Since the first $$$x$$$ characters of $$$s$$$ and $$$t$$$ will be equal after this operation, we can note this is identical to the initial problem but comparing $$$s$$$ with the first $$$x$$$ occurances of $$$t_1$$$ removed to $$$t[x + 1, n]$$$ instead of comparing $$$s$$$ to $$$t$$$.
    • So we set $$$cost = cost + \sum_{i = 1}^{x} {pos_i - i}$$$ and repeat the process for the first block of the newly obtained strings.

So we effectively are repeating the process of case 2 for each block in order, and take the min of case 1 for each block.

However this still runs in $$$O(blocks * n)$$$, and the number of blocks can be upto $$$n$$$ (all characters different), so this is still $$$O(n ^ 2)$$$ in the worst case.

Suppose there exists some $$$t_i \gt t_{i + 1}$$$. Lets say we have processed the blocks upto index $$$i$$$ and made $$$s[1, i] = t[1, i]$$$ at some cost $$$c$$$. Now to proceed with this process we will have to make $$$s_{i + 1} \leq t_{i + 1}$$$. Let the cost of the moves for this be $$$d$$$. But it will take only one more move than this to make $$$s_{i} \lt t_{i}$$$ since $$$t_{i} \gt t_{i + 1}$$$.

So we know the answer is $$$\textbf{AT MOST}$$$ $$$c + d + 1$$$, and that the answer for any further block is $$$\textbf{AT LEAST}$$$ $$$c + d$$$. This $$$c + d$$$ is only achievable when $$$d = 0$$$ and $$$s[i + 1, n] \lt t[i + 1, n]$$$ which can be checked for in $$$O(n)$$$ time.

If a block has a smaller character than its preceding block we can immediately check if there is an optimal answer from a further block and don't need to check further blocks one by one. So we only care about at most the first 26 blocks. So our solution now runs in $$$O(min(blocks, 26) * n)$$$ which is clearly good enough for the given constraints.

Submission — 141162437 (with comments), 141162629 (without comments)

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

Can someone explain how do you use bitsets in F? Isn't it mod 3?

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

    Same question here...

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

      This is a simple way to implement vectors in $$$\mathbb Z/3\mathbb Z$$$ using bitsets (not sure about the efficiency though):

      Spoiler

      If necessary, it can be optimized by keeping only val[0] and val[1], since val[2] can be recovered as val[2] = ~val[0] & ~val[1].

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

        Thanks. Btw, I think you meant vals[0][id] = vals[1][id] = vals[2][id] = 0;

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

        Thanks to this I implemented the same gauss function from cp-algo, and it barely squeezed into time limit ~950ms, after optimizations turning bitset3 * 2 and bitset3 * (-1) into swap(bit[1],bit[2]): 141828486.

        Without bitset optimizations I passed with ~150ms with same gauss function but with array, and obvious calculation fix: if you can color all edges into one color do so and don't call gauss: 141818760

        EDIT: If someone has better/faster implementation I could use, please post it here :)

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

Problem C can also be solved in O(n^2 log(n)) by just selecting one element at a time(ith element) and then we will calculate the value of d for every other element (d is the common difference by which we can reach jth element without altering the jth element) and we will store it in a map. The maximum value of d(maxd) which has occurred is the number of element which we do not have to change plus the ith element. So the ans will be n-1-maxd .

    int n;
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans=1e9;
    for(int i=0;i<n;i++){
        map<pii,int> mp;
        int mx=0;
        for(int j=0;j<n;j++){
            if(i==j)continue;
            int tot=abs(j-i);
            int diff;
            if(i>j)diff=a[i]-a[j];
            else diff=a[j]-a[i];
            int sign=1;
            if(diff<0)sign=-1;
            diff=abs(diff);
            int g=__gcd(diff,tot);
            diff/=g;
            tot/=g;
            diff*=sign;
            mp[{diff,tot}]++;
            mx=max(mx,mp[{diff,tot}]);
        }
        int change=n-1-mx;
        ans=min(ans,change);
    }
    cout<<ans<<endl;
»
4 года назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

problem C why it is failing on testcase 7

141145372 this is my submission id

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

    Could be due to the precision of your float "delta". You can avoid the float arithmetic by checking

    "(arr[k]-arr[i])*(j-i) != (arr[j]-arr[i])*(k-i)",

    which is essentially checking if the deltas of the k-i sequence and the j-i sequence are the same:

    (arr[k]-arr[i])/(k-i) != (arr[j]-arr[i])/(j-i)

    141178264 for reference.

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

Here are alternative ideas for D and E using two pointers.

D: the first thing to notice is that we can simplify the condition. In this case if we subtract x from all a_i the condition simplifies to having the sum of values in all subsegments be greater than 0. Now all we have to do is use two pointers and greedy. Start the two pointers at the start of the array. Increase the right pointer while this sum is negative. If the current segment length is greater than 1 unselect the last value and set the left and right pointers to after this value. Repeat until you get to the end of the array. Additionally if the sum ever gets greater than or equal to 0 and the segment size is greater than 1 then we should increase the left pointer until it becomes negative or the segment size becomes equal to 1.

E: First notice that there must be a prefix of values where a_i=b_i followed by one value where a_i>b_j. In order to make a<b it is necessary to change one of the values in this prefix or single value. Otherwise a will still be greater than b. It's pretty obvious that we only need to swap to values in a. The answer is the distance between these two values. Let's call these two positions i and j. Without loss of generality the final result of this swap will be a[i] = a[j]. We also know that for this result to work we need it to be the case that a[i]<b[i] after the swap. Therefore we simplify the problem to finding the minimum value of j-i where a[j]<b[i], j>i, and i is a position in the prefix before and including the first different value between a and b (which we will now notate as i<=P). Now we use a common greedy trick where we notice that many values of i and j are unoptimal. In particular we will only keep values so that when i<j, b[i] > b[j] and a[i] > a[j]. This means that we have two monotonic sets for a and b which we can choose from. From here we simply apply a two pointers technique in which i=P and j=N. We decrease j as much as we can while a[j]<b[i]. Then we decrease i. In total this gives us the answer in O(N).

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

Problem E:

How can Binary Indexed Tree be useful? I'd be grateful if someone explained.

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

    let's say we have this array

    1 2 3 4 5 6
    a b c d e f
    

    if we wanna remove d, now e index becomes 4, and f index becomes 5.
    so using Fenwick tree we can maintain the new index using prefix sum
    let's first initialize the the BIT array with ones

    1 2 3 4 5 6
    1 1 1 1 1 1
    

    if you noticed the prefix sum for each index is the index it self
    now let's remove d again (index 4) and add -1 so that it will be 0

    1 2 3 4 5 6 
    1 1 1 0 1 1 
    

    prefix_sum

    1 2 3 3 4 5
    

    now if you noticed the prefix sum of 5 and 6 will reflect the new index 4 and 5
    hope this helps.

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

      Thanks.

      What if we want to insert some character somewhere in the middle?

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

        I was wondering about the same. Rather than viewing it as the updated index, it's helpful to view prefix_sum($$$pos$$$) as "the number of unprocessed characters in the range $$$s[1..pos]$$$ (1-based indexing)". Here, unprocessed characters are those that have not been used so far in the process of equating the prefixes (and are thus coming in the way of moving our desired character to the end of the prefix). With this view, the "inserting in the middle" question doesn't arise.

        In the above example, say that 'd' is moved to position 1, so that now both $$$s$$$ and $$$t$$$ match up to position 1. Now for position 2, suppose we want to bring in 'c'. We have prefix_sum(2)=2 so the cost is 2 steps. Instead, if we want to bring in 'e', the cost is prefix_sum(4)=3 steps.

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

    https://mirror.codeforces.com/contest/1616/submission/141260604 see the code i have added comments to explain the approach

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

The editorial for problem G seems to have "a -> b" in the reversed/wrong order.

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

can somebody explain d in detail after subtracting x what is to be done?

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

Hello. I can't understand why my solution of D problem isn't working. I told that we can use some kind of greedy algorithm. Let's choose every number from prefix in our array. So if our prefix i isn't available(it's organize not possible situation), so we just don't mark this, in other case we just mark that number and go for i + 1. In that situation we know that for every possible combination of l and r < i problems statement is correct, so we should just check the case there i equal to r and compute the minimum avg_number for all possible l. If that minimum avg_number < x we don't mark x. I barely can understand why this isn't a solution for this problem. Can someone explain why this isn't working and probably give me not such a big sample of this? 141117167 — my submission. I understand that it's working with square n time, but problem with Wrong Answer and it's not very hard to organize nlog(n) time complexity.

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

    Let's suppose $$$x = 1$$$, so that the second condition is simplified to: The subsegment sum should be greater than the subsegment length. If you consider this simple testcase

    1
    3
    2 1 -4 
    1
    

    You can see that $$$[2, 1]$$$ is a valid subsegment, because $$$\Sigma [2, 1] \geq 2$$$ and $$$[1, -4] \Longrightarrow -4$$$ is not a part of the selection, and $$$[2, 1, -4] \Longrightarrow -4 $$$ is not a part of the selection.

    Hence, the maximum number of candidates is 2, while your code produces 1.

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

Can anybody please give a counter testcase for my solution for problem C (WA on test 3). 141135074

And I would also like to hear some tips about how to debug the solution if my approach is right? Since last 4-5 contests I am getting the approach and key observations right but not able to code it correctly. How to improve upon this?

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

For problem E's solution: "In general, we can easily see that the optimal strategy is to move characters one by one, every time choosing the closest character".

How can we prove that this is true?

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

For C, i thought about each element v[i] as being a point in the plane (v[i],i). If a point k is in the same arithmetic progression as points i and j, then (v[i],i), (v[j],j) and (v[k],k) are colinear. That way you just do shoelace theorem to see if the area of the polygon of those 3 points is 0. Code: 141085542

Im currently in a war to let the geometry tag be on C rn

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

can anyone help me with problem B I'm getting WA 141164645 is my sumbission

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

Regarding question C, why is my co``de wrong in the seventh sample? Have a good brother help me to see it, thank you,

Your text to link here...

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

Anyone solve problem F by local search ?

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

I did C using Geometry...

141250782

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

I got a RUNTIME_ERROR verdict on this solution: https://mirror.codeforces.com/contest/1616/submission/141075698. Can someone point out the problem? Unfortunately I can't view the full test case because it is very long.

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

Can someone please explain Note that there should be a negative-sum subsegment of length 2 or 3, if there is a negative-sum subsegment. It is easy to see as x<0,y<0⇒x+y<0.

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

in the 2nd question can anyone tell me, a or aa which appears earlier in dictionary. i guess a if so then why is there a test case that has aa as output

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

I’ve used a weird method accepting F in the contest.

Specifically, for each test case, I repeat several times doing the following things: 1. giving edges random value. 2. adjust it to minimize the ternary rings which is not same and not {1,2,3}. If the number of illegal ternary rings haven't changed for several adjusting operation, then I just do it again.

»
4 года назад, скрыть # |
 
Проголосовать: нравится -13 Проголосовать: не нравится

Many C solutions i saw had 3 loops inside each other, doesn't that make its time complexity O(n^3) ? If yes then how it gets accepted.

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

in problem D ,can someone prove why we check only negative sum segments with lengths 2 ,3 only??

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

    Assume that all sub segments of length >= 2 before i have positive sum, and we want to know whether there is sub segment ending at i such that sum(sub segment ending at i) < 0 then there are only two ways

    • a[i] + a[i — 1] < 0 (a[i — 1] >= 0, a[i] < 0 such that a[i] + a[i — 1] < 0 vice versa) or
    • a[i] + a[i — 1] + a[i — 2] < 0 (a[i] < 0, a[i — 1] >= 0, a[i — 2] < 0 vice versa)

    Note that we don't look at any other case because of the assumption we made in the starting(any sub segment we choose to combine will just increase the sum(sub segment ending at i)).

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

Thanks for contest! Really enjoyed problem E :)

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

Good!But H I can't understand

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

In D for those, who didn't come up with idea of segments sized 2 or 3, you can use segment tree over prefix sum of a[i] — x to find if the segment beggining in i is less then 0. In that case just exclude i and continue. 187614580

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

Solution to problem D Please upvote me