mesanu's blog

By mesanu, history, 7 months ago, In English

Hello Codeforces!

flamestorm, MikeMirzayanov and I want to invite you to Codeforces Round 898 (Div. 4).

It starts on Sep/21/2023 17:35 (Moscow time).

The format of the event will be identical to Div. 3 rounds:

  • 5-8 tasks;
  • ICPC rules with a penalty of 10 minutes for an incorrect submission;
  • 12-hour phase of open hacks after the end of the round (hacks do not give additional points)
  • after the end of the open hacking phase, all solutions will be tested on the updated set of tests, and the ratings recalculated
  • by default, only "trusted" participants are shown in the results table (but the rating will be recalculated for all with initial ratings less than 1400 or you are an unrated participant/newcomer).

We urge participants whose rating is 1400+ not to register new accounts for the purpose of narcissism but to take part unofficially. Please do not spoil the contest for the official participants.

Only trusted participants of the fourth division will be included in the official standings table. This is a forced measure for combating unsporting behaviour. To qualify as a trusted participant of the fourth division, you must:

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

Regardless of whether you are a trusted participant of the fourth division or not, if your rating is less than 1400 (or you are a newcomer/unrated), then the round will be rated for you.

Many thanks to the testers: Gheal, Phantom_Performer, KrowSavcik, haochenkang, sandry24, BucketPotato, Vladosiya, NintsiChkhaidze, erekle, Dominater069, MADE_IN_HEAVEN, Qualified.

We suggest reading all of the problems and hope you will find them interesting!

Good Luck!

UPD: Editorial is out!

  • Vote: I like it
  • +200
  • Vote: I do not like it

»
7 months ago, # |
  Vote: I like it +33 Vote: I do not like it

monthly leetcode contest let's gooooo!!! hope the statements are clear to everyone (so that we can ak faster)

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

So hapy for the round. I did't participate in a rated round for a long time.:)

P.S. I am not racist

»
7 months ago, # |
  Vote: I like it +5 Vote: I do not like it

My first unrating contest :)

»
7 months ago, # |
  Vote: I like it +22 Vote: I do not like it

As a tester, today K77 will score a goal. P.S problems are very nice.

»
7 months ago, # |
Rev. 2   Vote: I like it -49 Vote: I do not like it

Why?

  • Why isn't Division 4 prepared on a weekly or bi-weekly
    basis instead of being held every two months?
class vote:
    votes=0
    def __init__(self,state="up"):
        if state=="up":
            votes+=1
        else:
            votes-=1
upvote_me = int(input())
for i in range(upvote_me):
    obj = vote(state="up")

print(vote.votes) 

upvote pls ``)

  • »
    »
    7 months ago, # ^ |
      Vote: I like it +23 Vote: I do not like it

    Because we will get too many dumb specialists

  • »
    »
    7 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Theyre too hard i think there should be more div1 contests for new people, it's really dumb how there's only 2 every month...

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

this will be my first contest on this platform (unless im too lazy)

»
7 months ago, # |
  Vote: I like it +1 Vote: I do not like it

Where is SlavicG ?

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

This contest is gonna be fun!

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

all the best !

»
7 months ago, # |
  Vote: I like it +1 Vote: I do not like it

First unrated contest for me !!

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

What are my chances? 0-don't even try 1-maybe you will solve just one 2-averege 3-i belive in you 4-all the way to the top

  • »
    »
    7 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Its div4, i think you have great chances, idk you, but at least 2

    Good Luck! Ill pick 3 cause i believe in you

»
7 months ago, # |
  Vote: I like it +7 Vote: I do not like it

its been ages since the last time problem ratings were updated. :feelsoldman:

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Thanks for this round

I will be happy to participate in this round

Best Wishes

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

My First Unrated Round

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

how long will the contest last after the start time?

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Specialist here I come!!!

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Hopefully my last rated div4 :O

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

first time participating in an unrated div 4 round!!! TT

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Wishing for another enjoyable Div.4 round! :)

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Hope to get +300 this round

»
7 months ago, # |
  Vote: I like it -8 Vote: I do not like it

Div. 4 >>>>> all rounds

»
7 months ago, # |
  Vote: I like it +2 Vote: I do not like it

Finally First unrated contest

Spoiler
»
7 months ago, # |
  Vote: I like it +2 Vote: I do not like it

Bro really I was waiting for this day to participate in my first Div 4. contest and I can not register because of one rating point

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I only want 70 points:)

»
7 months ago, # |
  Vote: I like it -31 Vote: I do not like it
»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Genshin,Startup!

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

is it rated?

  • »
    »
    7 months ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    Regardless of whether you are a trusted participant of the fourth division or not, if your rating is less than 1400 (or you are a newcomer/unrated), then the round will be rated for you.

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

i am going to participate despite having chemistry exam tomorrow, sorry to mr Ratherford, Bohr, Thomson, Schrodinger, Higenberg and 69 others :)

»
7 months ago, # |
  Vote: I like it -6 Vote: I do not like it

Why aren't there more div4s i think once per month is too rare, we are noob we need more div4

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Going to participate in the contest after 2 years long break.

Hope, This will be a good one

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

My second round on this website and the first rated. In the first one I solved 2 tasks in the first hour and then 0 in the next four hours... I hope this one will go better.

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Good luck to everyone, I hope I can get specialist this round!

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Div 4 without SlavicG .....

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I don't like ICPC...But this is the only chance making my rating higher

»
7 months ago, # |
  Vote: I like it +7 Vote: I do not like it

average div4 round

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Very Excited!! I have solved 5 of them so far!

P.S. I am a newbie

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Cool problem set.

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Wow, that contest was amazing!!! I really hope that with such contests, I'll become green...

»
7 months ago, # |
  Vote: I like it +1 Vote: I do not like it

balanced problems and clear statements, this is defintion of a perfect contest!! thanks to the authors

»
7 months ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

This contest was quite nice... Can't wait for the next :) Codeforces Round 898 (Div. 4)

»
7 months ago, # |
  Vote: I like it +4 Vote: I do not like it

Loved the Kendrick Lamar references throughout the contest! The authors have good taste in music

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

WTF IS WRONG WITH PROBLEM F?

  • »
    »
    7 months ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    I see nothing wrong with F. Time wise, it took me much longer to solve G.

                   problem: A  B  C  D  E  F  G  H
      num_minutes_to_solve: 6  2 10  3  5 26 63 28
    
»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Nice round.

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

bruh imagine doing 5 problems in 18 minutes and being like top 50 or even better and then taking 2 hours for the sixth one, i don't understand what happened to my brain :((((((

  • »
    »
    7 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    same, was top 20 once, now 800th

  • »
    »
    7 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    bro how did you got the algorithm for D. I am not able to do it.I did first 3 and C been pretty average to me like its algo is repetitive.

  • »
    »
    7 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Same. But I stuck at problem E. Did anyone give some advises for solving binary search problems like this? I am too dumb to ensure the edge condition. Would I use mid = (l+r)/2 or(l+r+1)/2? give answer as l? or r? or mid? all gives me a lot trouble.

    • »
      »
      »
      7 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      hey how did you do D.

    • »
      »
      »
      7 months ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      you can use this trick:

      always write your code as

      while(l<=r){
         m=(l+r)/2;
         if(condition) l=m+1;
         else r=m-1;
      }
      

      here 2 thing to consider. 1st: lets say you want to binary search on a to b.condition is true for a but not for b i.e TTTTT...FFFFF then answer will be r. and for FFFF...TTTT answer is l. 2nd: in the "if condition" will there be < or <=. It will depend on problem like lets say we want largest number <=x in that case we cant take equality. otherwise in the base case l will exceed x. same logic can be used if we need number >x

      }

    • »
      »
      »
      7 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      The edge conditions also confused me a lot. You can actually use recursive functions to write the binary search algorithms just like building a segment tree ,which means you don't need to worry about the vague conditions any more.

      int solve(int l,int r) //The answer exactly belongs to [l,r]
      {
      	if (l==r)
      		return l;
      	
      	const int mid=(l+r+1)/2;
      	if (check(mid))
      	    return solve(mid,r);
      	return solve(l,mid-1);
      }
      

      We replace the variable mid into (l+r+1)/2 instead of (l+r)/2 because it always satisfies mid<=r and l<=mid-1. If mid is a valid answer then the interval would be shrunk into [mid,r]. Of course, if mid is an invalid answer we can just throw it out, so we choose solve(l,mid-1) instead of solve(l,mid). Details are very clear if you write the algorithm like this.

    • »
      »
      »
      7 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Thanks to all of you!

    • »
      »
      »
      7 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      C#, but should be almost exactly the same in C++

       static long BinSearch(Predicate<long> IsInRightPart, long l, long r, bool firstYes = true)
              {
                  while (l < r)
                      (l, r) = firstYes
                          ? (IsInRightPart((l + r) / 2)
                              ? (l, (l + r) / 2)
                              : ((l + r) / 2 + 1, r))
                          : (IsInRightPart((l + r + 1) / 2)
                              ? (l, (l + r + 1) / 2 - 1)
                              : ((l + r + 1) / 2, r));
                  return l;
              }
      
»
7 months ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

why is this code wrong for E? plz give me some advice. thx in advance.

include <bits/stdc++.h>

using namespace std;

long long num[200001]; long long dp[200001];

int main(void) { ios::sync_with_stdio(0); cin.tie(0);

int t;
cin >> t;
for(int i=0; i<t; i++)
{
    int n, x;
    cin >> n >> x;
    for(int j=0; j<n; j++)
       cin >> num[j];
    sort(num, num+n);
    dp[0] = num[0];
    for(int j=1; j<n; j++)
       dp[j] = dp[j-1] + num[j];
    long long st = 0, en = 4000000001;

    while(st+1 < en)
    {
       long long mid = (st+en)/2;
       long long tmp = lower_bound(num, num+n, mid) - num;
       if(tmp == n)
         tmp--;
       long long gap = mid*(tmp+1) - dp[tmp];
       if(gap > x)
         en = mid;
       else
         st = mid;
    }
    cout << st << '\n';
}

}

  • »
    »
    7 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    i did exactly same but don't know why it's not working

  • »
    »
    7 months ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    (not verified with code but just based on code review): The raw tmp value range is [0,n] and then adjusted to [0,n-1]. When tmp is 0, gap should be 0 instead. To fix, do not adjust tmp, but compute gap with:

      gap = mid * tmp - (tmp == 0 ? 0 : dp[tmp-1]);
    
»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

How to solve G?

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

please explain F

»
7 months ago, # |
  Vote: I like it +1 Vote: I do not like it

Duuuudeeee if I had like 1 minute, I would've solved the last problem yikes

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

A and B were pretty easy. C is just slightly above average and the code is repetitive. and I didn't able to 4th one. I got some math but it is throwing me an error in the first case itself but it solved almost 7 cases in it. Can anyone help me how to do it.

  • »
    »
    7 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Create a array that will contain only the index of every B.

    Now, iterate over the array using two pointers. If difference between two points exceed k(consecutive cells) simply add one to the answer and move your starting pointer.

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Please explain F

  • »
    »
    7 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Basically you will have to determine the maximum length of subarray of array a such that sum of every element in that subarray does not exceed k.

    However the the catch is, the subarray you are creating from a, those indices must also form a valid subarray of h. And subarrays of h is constructed following the condition: hi is divisible by h(i+1).

    So, for the following test case,

    1
    5 12
    3 2 4 1 8
    4 4 2 4 1
    

    subarrays of h are: 4 4 2 and 4 1. Notice that every element is divisible by the next element.

    One optimal subarray of a will be 3 2 4 since sum 9 is less than 12. And the length will be the answer.

    2 4 1 is also a subarray that has a sum lower than 12. But it does not overlap in any subarray of h. Therefore this subarray is not optimal.

    • »
      »
      »
      7 months ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      Thank you .i also tried to implement the sliding window solution but i overcomplicated the idea or messed with the approach. This was my code and it always for 2nd testcase.

      void solution()
      {
         ll n,k;
         cin>>n>>k;
         ll arr[n+1];
         ll h[n+1];
         for(ll i=1;i<=n;i++) cin>>arr[i];
         for(ll i=1;i<=n;i++) cin>>h[i];
         if(n == 1)
         {
           if(arr[1]<=k) cout<<1<<endl;
           else cout<<0<<endl;
         }
         else
         {
           ll j = 1;
           ll result = 0;
           ll sum = 0;
           ll i = 1;
           while(j<=(n) and i<=n)
           {
              if(j == n)
              {
                  if(i!=j and sum + arr[j] <=k)
                  {
                      result = max(result,(j-i)+1);
                  }
              }
              else
              {
                  if(h[j]%h[j+1] == 0)
                  {
                      sum += arr[j];
                      if(sum <= k)
                      {
                          result = max(result,(j-i)+1);
                      }
                      else
                      {
                          while(sum > k and i<=j)
                          {
                              sum -= arr[i];
                              i+=1;
      
                          }
                          if(i<=j)
                          {
                              result = max(result,(j-i)+1);
                          }
      
                      }
                      
                  }
                  else
                  {
                      if(i!=j and sum + arr[j] <= k) result = max(result,(j-i)+1);
                      i = j+1;
                      sum = 0;
                  }
              }
              j+=1;
           }
           cout<<result<<endl;
         }
         
      }
      
»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

great contest!

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

include<iostream> #include<bits/stdc++.h> using namespace std; int possible(vector<int> v,int mid){ int n = v.size(); int wdth = 0; for(int i=0;i<n;i++){ if(v[i]<mid){ wdth = wdth + (mid-v[i]); } else{ continue; } } return wdth; } int main(){ int t; cin>>t; while(t--){ int n; cin>>n; int w; cin>>w; vector<int> v; for(int i=0;i<n;i++){ int x; cin>>x; v.push_back(x); } int low = 1; int high = w + accumulate(v.begin(),v.end(),0); int ans = -1; // binary search on heights while(low<=high){ int mid = low + (high-low)/2; if(possible(v,mid)<=w){ low = mid + 1; int cnt = mid; ans = max(cnt,ans); } else{ high = mid - 1; } } cout<<ans<<endl; } }

i applied checked width for every height from lower to upper bound and applied binary search on heights it passed 3 test cases whats the problem ?

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Why showing penalty currently in the standings? I didn't do wrong submissions?

  • »
    »
    7 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    penalty is total of time you need to get AC all problems. If you haven't AC a problem (except WA on test 1), then 10 minutes is added to your penalty when you AC that problem.

»
7 months ago, # |
  Vote: I like it +1 Vote: I do not like it

pwild can you please explain this beautiful solution of yours for G?

  • »
    »
    7 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Imagine the character 'B' will divide $$$s$$$ into some parts of consecutive 'A'. Then the answer is just the total 'A' in $$$s$$$ minus the minimum number of 'A' among all these parts.

  • »
    »
    7 months ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    zackscott286 already explained what the code does. To get there, note that we can get rid of any sequence of 'A' as long as there is a 'B' next to it, but that a single 'B' can only be used to eliminate either the sequence to its left or the one to its right. As the number of 'A' sequences is one more than the number of 'B', one of the 'A' sequences needs to stay, and we can always ensure that we only keep the shortest. The maybe somewhat surprising part of this is that this still works if this shortest sequence is empty, i.e. if the string starts or ends with 'B' or contains a substring 'BB'.

»
7 months ago, # |
  Vote: I like it +10 Vote: I do not like it

MY INTUTION FOR THE LAST ONE IS. ONLY ONCE CYCLE EXISTS IN THE GRAPH IF IT DOES. FIND WHERE THE PERSON RUNNING CAN ENTER IT. THEN SEE WHO CAN REACH IT FIRST. IF THE PERSON RUNNING CAN REACH IT FIRST ITS A YES OR ELSE A NO. AM I RIGHT? I COULD NOT DO IT COZ I WENT TO EAT A CAKE.

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

When you've spent a whole hour coming up with a solution for H when there are 1 to n*(n-1) edges, and only after the solution was found do you notice that there are only 1 to n edges =|

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Thank you for this great contest! I'm so happy that I solved 3 problems in 30 minutes

»
7 months ago, # |
  Vote: I like it +9 Vote: I do not like it

Problem E is nice, came up with binary search fast but spent lots of time fixing the high bound, lesson learned for me.

Problem G is so nice, with short and clear statement, like it the best in this contest!

Thank you guys for the contest!

  • »
    »
    7 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    how did you fix the high bound?, I tried a lot of things still couldn't do it

    • »
      »
      »
      7 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      The key here is just to make sure it won't be overflow between long long and int.

      In your submission with end=2e14 then mid will be 1e14, in function isPossible variable w may become 2e19 (overflow for long long) because n can be max 2e5.

  • »
    »
    7 months ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    When calculating the sum, if we exit the loop just after it exceeds x, then, we don't have to worry about the high bound.

    (In your case it is in method check, for the variable cnt. If we add if (cnt > x) return false;, it would have probably worked, even with the maximum long value as the high bound.)

»
7 months ago, # |
  Vote: I like it +3 Vote: I do not like it

For problem F: Given, (l≤i<r). Here, How l and r can be same? That means (l==r)?

Please explain some one...

  • »
    »
    7 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Yeah, it is confusing. But you can choose subsegment of length 1 if a[i] <= k

  • »
    »
    7 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Yeahh I also had a chat with them on this. They didn't mentioned anything about subarray of size 1.

  • »
    »
    7 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    There's no such $$$i$$$, so, no such constraint too. If $$$r=l+1$$$, we have to ensure $$$h_l$$$ is divisible by $$$h_r$$$. If $$$r=l$$$, there's nothing we have to ensure. You can also find such case in the 3rd example

    • »
      »
      »
      7 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I just ignored the note,, actually by reading the statement i was oversure that l must less than r.

  • »
    »
    7 months ago, # ^ |
      Vote: I like it +3 Vote: I do not like it
»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I think C and D should be swapped. C was harder question.I did not observe C, somehow I escaped with some implementation but costed me so much time.

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

One of the best and most Balanced Div 4 i saw there was so happy to take part in it

»
7 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Can someone help me find issue in F? I am not finding any case where it is failing. TIA https://codeforces.com/contest/1873/submission/224511926

»
7 months ago, # |
  Vote: I like it +1 Vote: I do not like it

Does problem F, test 2, test case 1: n = 2, k = 15, a = {9, 6}, h = {1, 3} exists a contiguous subarray satisfies the condition that each i (l <= i < r), h_i is divisible by h_(i+1)? The expected answer is 1, but there is no h_i is divisible by h_(i+1), so I think there is no contiguous subarray satisfies the condition. Please explain.

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

For Problem E how are we supposed to fix the upper bound while using binary search

I never thought upper bounds could be an issue. I assumed taking high bound as LLONG_MAX-1 should suffice always

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I wonder why I have rank 6900 with 5 problems while there are people with 4 problems and rank 6000 or even higher. Should It be the one with more problems has higher rank and only if there is a tie the time penalty plays a role?

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I was surprised by my friend's submission in problem E. He used greedy that I couldn't think it was possible LOL. His submission: 224456152

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

W Kendrick Lamar Problem Setters

»
7 months ago, # |
  Vote: I like it +3 Vote: I do not like it

Nice contest! I really enjoy it

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Were some of the problems in the contest inspired by Kendrick lamar?

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Can someone please explain what is wrong with my approach for problem F void solve() { ll n, k; cin >> n >> k;

ll a[n]{};
inp(a, n);
ll h[n]{};
inp(h, n);

ll pref_sum[n + 1]{};
for (ll i = 0; i < n; ++i) {
    pref_sum[i + 1] += pref_sum[i] + a[i];
}

ll ans = 0;
for (ll i = 0; i < n; ++i) { 
    ll start = i;
    while (i < n - 1 && (h[i] % h[i + 1] == 0)) {
        if (pref_sum[i + 1] - pref_sum[start] <= k) {
           ans = max(ans, i - start + 1);
        }   
        else
            break;

        ++i;
    }
}

cout << ans << nl;

}

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Please try to hack this Problem F

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Why cf tracker, carrot etc etc chrome extension is not working after div 4??

»
7 months ago, # |
  Vote: I like it +5 Vote: I do not like it

Some of the problem names reference Kendrick's songs, right?

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Hey , it was my first contest on codeforces , I am trying to understand which contest is rated and unrated , as the paragraph suggests that the contest was rated for everyone who was having a ranking less than 1400 but in my profile it shows under the contests section that it was an unrated one ? what am i missing out? is there any rule that first 5 contests would be unrated aur so?

  • »
    »
    7 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Codeforces contests can be rated or unrated, but it's not based on your rating or the number of contests you've participated in. Check the official contest details for the specific contest's rating status. There's no rule that the first 5 contests are unrated, each contest is individually rated or unrated by the organizers.

    • »
      »
      »
      7 months ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      Ohh... in this post it is written that "Regardless of whether you are a trusted participant of the fourth division or not, if your rating is less than 1400 (or you are a newcomer/unrated), then the round will be rated for you" that why i am like confused i remember that in the contest details it was written that the contest is a rated one , do the rankings come after a day or wot?

»
7 months ago, # |
  Vote: I like it +5 Vote: I do not like it

In queueueueueueueueueueueue!!!

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Problem E and F are really amazing problems

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Oh I missed the Div.4 again:(

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Hello All,

I am new to this platform. I recently participated in Codeforce round 898 div-4. But still ratings isn't updated yet. Open hacking phase is already completed.

Can anyone tell me what's the procedure or is this contest unrated ?

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Can any one tell me about which time ratings of this round will come (Codeforces Round 898 Div 4)

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

My first cf contest!!! For a freshman.

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I solved Problem B when the contest was running! and it was accepted. But now it's showing time limit is exceeded. Why?

  • »
    »
    7 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
    This may go into infinite loop!
»
7 months ago, # |
  Vote: I like it +1 Vote: I do not like it

Kendrick Round

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

YAY! I'M CYAN

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

The most painful thing is when you solve around 6 problems on Codeforces,
gaining, let's say, +100, and then the last problem gets removed after the testing phase.

It really hurts:(

I know that I am newbie, but it still hurts:(

»
7 months ago, # |
  Vote: I like it +8 Vote: I do not like it
  • »
    »
    7 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    it may be only a coincidence.

  • »
    »
    7 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Another coincidence with Luogu Monthly Contest... Hope that the authors can check their problems in Chinese websites (such as Luogu) before the round in the future.

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

very nice binary search problem

»
7 months ago, # |
  Vote: I like it +1 Vote: I do not like it

You can also watch the video editorials I made on the problems E , F, G and H

Enjoy watching and let me know what you think about them!

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I was doing questions in random order. I had written a rough pseudocode on ideon.com of 1863D problem latest Codeforces Round 898 (Div. 4) for writing code later and unfortunately it was in public mode. I don't know man someone took my idea and submitted the solution before me by translating the pseudocode into actual code. Apologies for this unintentional action. I will make sure this won't happen again.

Thanks

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

hey i have got an mail telling that my solution 221323129 coincided with other people .but i dont have any solution with that code. how do i even check it?

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Hi can anyone give me edge case for problem H been confused for a long time whats the issue with my code . Thanks in advance !!

Submission = 224828768

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I'm sorry for using ideone.com

Supposedly, out of the five that I solved, it's showing (that Solution B) of mine coincides with a couple of people, in a hurry while submitting I accidentally used ideone.com with public display settings, Sorry for that

Proof: https://drive.google.com/file/d/17RVpgMSCirhaVRcfAAACe9_cnKEhVPLd/view?usp=sharing

Sorry :/

  • »
    »
    7 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Bro, how do you code in 6 different languages : python, c#, ruby, java, go, c++.. Thats just insane ! :o

  • »
    »
    7 months ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    Bro was trying to avoid plagiasm check, but got caught anyways :)

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I want to clarify that the similarity between my solution (224380982) for problem 1873C and the solution by Anonymous_P (224476541) was purely coincidental and occurred due to the unintentional public access of my code on onecompiler.com (which I had no idea about). My submission, under the username redder02, was made at 20:37, while Anonymous_P's submission was at 22:07, clearly indicating that my code was posted well before theirs. I take the rules seriously and request you to consider this timeframe in your evaluation.

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Okay so got a message from system that my solution got coincided with the solution of some other person whom I do not know at all My solution: https://codeforces.com/contest/1873/submission/224426160

The other one: https://codeforces.com/contest/1873/submission/224487303

The only thing seems similar in the codes is the logic that is checking the conditions updating the variable neither do I use any platform where my solution can get leaked nor do I know the other person. It was just a pure coincidence since the solution was simple. Kindly review it.

»
5 months ago, # |
  Vote: I like it 0 Vote: I do not like it

well in the third problem "Target Practice" the output is wrong.

»
3 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Can anyone please find any exception for my source code for G? I think my code is correct but it gets wrong on test 2. My submission: 246793693.