Code : #include using namespace std; #define ll long long int main() { ll t, n, m, k, i, j, max_f, max_e; cin>>t; for(;t--;) { cin>>n>>m>>k; if((n%k)==0){ max_f=n/k; max_e=k; }else{ max_f=n/k+1; max_e=(n%k); }
Sir no. of colors with max frequency kyu define krna pd rha h, vo to a1 +a2 +a3...=n se apne aap hi satisfy hojaayega,,,,for eg.n=20,k=5 mei 5 se zyaada 4 frequency vaale color ka testcase is not possible kyuki a1 +a2...=n vaala constraint violate hojaayega
Suppose n=19, k=7, so maximum frequency of elements could be 3 and no of such elements would be 5 and suppose frequency of elements is 3 3 3 3 3 3 1. Here also sum of frequencies is 19 but elements having maximum frequency i.e 3 is 6, which is not possible. So we have to check that. I hope you got my point.
Code :
#include
using namespace std;
#define ll long long
int main()
{
ll t, n, m, k, i, j, max_f, max_e;
cin>>t;
for(;t--;)
{
cin>>n>>m>>k;
if((n%k)==0){
max_f=n/k;
max_e=k;
}else{
max_f=n/k+1;
max_e=(n%k);
}
ll a[m];
for(i=0; i>a[i];
}
for(i=0; imax_f){
max_e=-1;
break;
}
}
if(max_e
Now I understood the question and solution .In contest I was struggling to solve such a question
++
I was so close
Good Explanation.
damn you're explanation is just too good!! Thank you newton school and Karan bhaiya ♥
super clean explanation🛐
You are top G
i cried in this problem, was not able to solve since march of this year
sir aaese question ni ho rahe...kis rating k question practice karne chaiye? Help
thanks for the video bhai
Will you make solution for problem C, D?
Probably tomorrow...
Education round 140 question number C
You are great
Make for C,D and further
Probably tomorrow...
Sir no. of colors with max frequency kyu define krna pd rha h, vo to a1 +a2 +a3...=n se apne aap hi satisfy hojaayega,,,,for eg.n=20,k=5 mei 5 se zyaada 4 frequency vaale color ka testcase is not possible kyuki a1 +a2...=n vaala constraint violate hojaayega
Suppose n=19, k=7, so maximum frequency of elements could be 3 and no of such elements would be 5 and suppose frequency of elements is 3 3 3 3 3 3 1. Here also sum of frequencies is 19 but elements having maximum frequency i.e 3 is 6, which is not possible. So we have to check that. I hope you got my point.
@@codingcommunitynewtonschoo8582 ohh got it,didnt think of this
@@codingcommunitynewtonschoo8582 thanks sir
sir your solution got hacked in this contest . so is this the right intuition behind this question?
I had given 2 solutions where pretests passed. Both had a bit difference. May be the first one might have got hacked...
Bro what is the Karan Sir Codeforces ID Except karan984
@@codingcommunitynewtonschoo8582 code dedo sir
Checked out the pinned comment !
Mine solution is accepted...
Problem C-
Probably tomorrow...
kis ka solution hack hogya?🙂
Code kha hai
Check out the pinned comment...