it was just maths... nice explanation sir... The best part about you is that You make us understand how to think ... so that next we dont get stuck in similar question.. Thank you sir.
@KaranMashru2 жыл бұрын
Code : #include using namespace std; #define ll long long int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll t, n, k, b, s, i, ans; cin>>t; for(;t--;) { cin>>n>>k>>b>>s; if((k*b+n*(k-1))
@worldfromhome40332 жыл бұрын
Sir in a[0] why did you add min(k-1,s) and not just k-1?
@codingcommunitynewtonschoo85822 жыл бұрын
Suppose after adding b*k to a[0], the remaining value of s=5 and value of k-1=7. Now, since we want to the sum to be exact s, the final value of s should be exact 0, bcoz we subtract array elements from it. So, now we add 5 and not 7. Similarly, if value of s remaining is 10 and value of k-1=7, then we add 7 only. Bcoz adding values greater than k-1 will increase the beauty value and hence it will not remain b. I hope you got my point.
@craftsworld32372 жыл бұрын
11:54 me loop 1 se nhi chalna chahiye? a[0] to pehle hi hm kb define kar chuke h na hm
@001_kavyagaur5 Жыл бұрын
No buddy loop 0 se hi start hoga kyuki first element ki max value k*b + k-1 tk hoskti h
@parthvaghela78202 жыл бұрын
Hats off for consistency !! Keep going, you're doing a great job!!!
@RohitBindalMusic2 жыл бұрын
Mene same approach use kar ke solve kar liya tha ye question contest mei but somehow I was not satisfied with my solution but after watching your video now I’m crystal clear ❤️ Thank you for your efforts 🙏🏻
@FinanceMode142 жыл бұрын
thank you sir for explaination 🙏🏻
@omkarsase65182 жыл бұрын
Good Explanation🙏🙏
@Super-lj1rf Жыл бұрын
thanku sir 💖💖
@hritikanand9734 Жыл бұрын
osm
@kky7811 Жыл бұрын
Thanks 🙏
@mridul10752 жыл бұрын
good explaination
@armed37192 жыл бұрын
I saw the answers of others almost everyone came up with the range solution.How? I was not able to think that way
@codingcommunitynewtonschoo85822 жыл бұрын
One of the things to notice here is that, for output they said that if no such array exists print -1. So if you figure out the condition of -1 i.e no such array possible , a lot of things will get cleared. So if you think in this direction you will realize that s can have a range of values for a given b, n and k. So if s lies in this range, solve further otherwise print -1. I hope you got the idea how we can approach such things.
@ayushnautiyal79652 жыл бұрын
Same
@girishbhargava63672 жыл бұрын
What would be the expected rating of this question?
@rudranilacharya52932 жыл бұрын
Sir please explain monoblock
@dam78542 жыл бұрын
what is the difficulty of this question?
@vedantkakade2 жыл бұрын
sir but i think this logic might fail at test case 2 5 5 30 where it will print 25 4 and sum of array will be less than expected sum.
@codingcommunitynewtonschoo85822 жыл бұрын
No this logic will store 29 1 . So sum will be 30 and beauty will be 5. I hope you got the point.
@harikeshsingh932 жыл бұрын
bhaiya c ka solution bhi upload kr do
@omkarsase65182 жыл бұрын
regarding max sum if first ele has value k*b then there will be n-1 ele remaining and for each ele value will be k-1 so sholud it be (k * b) +((k - 1)*(n-1)) ? (k * b) +((k - 1)*(n-1)) by using this I got wrong ans
@codingcommunitynewtonschoo85822 жыл бұрын
Max sum is (k*b)+(n*(k-1)), bcoz you can add k-1 to first element also. This will make first element k*b+k-1. It will still give beauty value as b. I hope you got my point.
@omkarsase65182 жыл бұрын
@@codingcommunitynewtonschoo8582 Understood sir. Thanks for clearing my doubt
@Shubham_adi_com2 жыл бұрын
Sir python+java
@Shubham_adi_com2 жыл бұрын
Sir mei coding free me kaha se shikhe
@ssv60552 жыл бұрын
bhaiya ,title change kardijiye
@codingcommunitynewtonschoo85822 жыл бұрын
😅 done. Thank you
@GauravKumar-kd9pp2 жыл бұрын
I was able to solve the question and passes all the pretests but while testing it Gave runtime error on 13th test case and then I observed that for k = 1 my code will give error and able to solve later. 🥲 From 7000 my rank reached 11k . 🥲🥲