Shayan's blog

By Shayan, 19 months ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, not as a substitute for the text editorial.

2019A — Max Plus Size

Video

2019B — All Pairs Segments

Video

2019C — Cards Partition

Video

2019D — Speedbreaker

Video

2019E — Tree Pruning

Video
  • Vote: I like it
  • +45
  • Vote: I do not like it

| Write comment?
»
19 months ago, hide # |
Rev. 2  
Vote: I like it +3 Vote: I do not like it

Update: Now Videos are playing. Thank you Shayan for the video tutorial.

Video tutorials are not playing! It shows this error An error occurred. Please try again later. (Playback ID: dLE5_mB8I9IVhzlN)

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

This is some text.

I HAVE A DOUBT REGARDING C PROBLEM. I WONDER HOW THIS SOLUTION WORKS??IT SHOULD FAIL BECAUSE- (first see the solution ,then read my doubt).

DOUBT- If we add some cards to the deck suppose "k".In this case the mx(highest frequency of card) may also increase??and we are checking for each possible size of deck (from 1 to n) that if the condition no.of decks>=mx holds.

(but mx can increase if we buy some card??then how this solution is working??)

// this is code

include <bits/stdc++.h>

using namespace std;

define ll long long

int main() { int t; cin >> t; while (t--) { ll n, k; cin >> n >> k; int chk=0; ll mx = -1,sum=0; vector a(n); for (ll i = 0; i < n; i++) { cin >> a[i]; sum+=a[i]; mx = max(mx, a[i]); }

ll ans=1;

    for (ll i = 1;i<=n; i++) {

        if (((sum+k)/i>=mx)&& (sum+k)/i * i >=sum) {
            //no. of deck>=mx & total cards>=sum

            ans=max(ans,i);
        }


    }
    cout << ans << endl;

}

}

The rest of the text.