Codeforces Round 816 Div 2 | Problem B : Beautiful Array Solution | InHindi | Explanation + Code

  Рет қаралды 3,887

Coding Community | Newton School

Coding Community | Newton School

Күн бұрын

Пікірлер: 35
@nitishbyahut25
@nitishbyahut25 Жыл бұрын
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.
@KaranMashru
@KaranMashru 2 жыл бұрын
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))
@worldfromhome4033
@worldfromhome4033 2 жыл бұрын
Sir in a[0] why did you add min(k-1,s) and not just k-1?
@codingcommunitynewtonschoo8582
@codingcommunitynewtonschoo8582 2 жыл бұрын
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.
@craftsworld3237
@craftsworld3237 2 жыл бұрын
11:54 me loop 1 se nhi chalna chahiye? a[0] to pehle hi hm kb define kar chuke h na hm
@001_kavyagaur5
@001_kavyagaur5 Жыл бұрын
No buddy loop 0 se hi start hoga kyuki first element ki max value k*b + k-1 tk hoskti h
@parthvaghela7820
@parthvaghela7820 2 жыл бұрын
Hats off for consistency !! Keep going, you're doing a great job!!!
@RohitBindalMusic
@RohitBindalMusic 2 жыл бұрын
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 🙏🏻
@FinanceMode14
@FinanceMode14 2 жыл бұрын
thank you sir for explaination 🙏🏻
@omkarsase6518
@omkarsase6518 2 жыл бұрын
Good Explanation🙏🙏
@Super-lj1rf
@Super-lj1rf Жыл бұрын
thanku sir 💖💖
@hritikanand9734
@hritikanand9734 Жыл бұрын
osm
@kky7811
@kky7811 Жыл бұрын
Thanks 🙏
@mridul1075
@mridul1075 2 жыл бұрын
good explaination
@armed3719
@armed3719 2 жыл бұрын
I saw the answers of others almost everyone came up with the range solution.How? I was not able to think that way
@codingcommunitynewtonschoo8582
@codingcommunitynewtonschoo8582 2 жыл бұрын
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.
@ayushnautiyal7965
@ayushnautiyal7965 2 жыл бұрын
Same
@girishbhargava6367
@girishbhargava6367 2 жыл бұрын
What would be the expected rating of this question?
@rudranilacharya5293
@rudranilacharya5293 2 жыл бұрын
Sir please explain monoblock
@dam7854
@dam7854 2 жыл бұрын
what is the difficulty of this question?
@vedantkakade
@vedantkakade 2 жыл бұрын
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.
@codingcommunitynewtonschoo8582
@codingcommunitynewtonschoo8582 2 жыл бұрын
No this logic will store 29 1 . So sum will be 30 and beauty will be 5. I hope you got the point.
@harikeshsingh93
@harikeshsingh93 2 жыл бұрын
bhaiya c ka solution bhi upload kr do
@omkarsase6518
@omkarsase6518 2 жыл бұрын
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
@codingcommunitynewtonschoo8582
@codingcommunitynewtonschoo8582 2 жыл бұрын
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.
@omkarsase6518
@omkarsase6518 2 жыл бұрын
@@codingcommunitynewtonschoo8582 Understood sir. Thanks for clearing my doubt
@Shubham_adi_com
@Shubham_adi_com 2 жыл бұрын
Sir python+java
@Shubham_adi_com
@Shubham_adi_com 2 жыл бұрын
Sir mei coding free me kaha se shikhe
@ssv6055
@ssv6055 2 жыл бұрын
bhaiya ,title change kardijiye
@codingcommunitynewtonschoo8582
@codingcommunitynewtonschoo8582 2 жыл бұрын
😅 done. Thank you
@GauravKumar-kd9pp
@GauravKumar-kd9pp 2 жыл бұрын
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 . 🥲🥲
Educational Codeforces Round 134 Div 2 | Problem B : Deadly Laser Solution | In Hindi | Editorial |
10:55
Beautiful Array | Detailed Explanation of Multiple Solutions
15:21
Tanishq Chaudhary
Рет қаралды 709
Random Emoji Beatbox Challenge #beatbox #tiktok
00:47
BeatboxJCOP
Рет қаралды 48 МЛН
这是自救的好办法 #路飞#海贼王
00:43
路飞与唐舞桐
Рет қаралды 93 МЛН
兔子姐姐最终逃走了吗?#小丑#兔子警官#家庭
00:58
小蚂蚁和小宇宙
Рет қаралды 15 МЛН
2 MAGIC SECRETS @denismagicshow @roman_magic
00:32
MasomkaMagic
Рет қаралды 27 МЛН
Awoo's Favorite Problem || Codeforces Educational Round 130 Div2 Problem C
14:24
Competitive Coding - Newton School
Рет қаралды 7 М.
Educational Codeforces Round 143 Div 2 | Problem C : Tea Tasting Solution | Newton School
27:53
Coding Community | Newton School
Рет қаралды 1,8 М.
Codeforces 1726A Solution | Mainak and Array
7:15
Coding Dynamo
Рет қаралды 1,4 М.
Min-Max Array Transformation || Codeforces Educational Round 134 Div2 Problem C
19:57
Competitive Coding - Newton School
Рет қаралды 4,2 М.
Codeforces Round 857 Div 2 | Problem B : Settlement Of Guinea Pigs Solution | Explanation + Code
19:35
Raspberries | Codeforces 1883C Solution | Codeforces Round 905 (Div.3)
12:42
Codeforces Round 816 All Solutions
2:23:30
SecondThread
Рет қаралды 7 М.
Random Emoji Beatbox Challenge #beatbox #tiktok
00:47
BeatboxJCOP
Рет қаралды 48 МЛН