Nice question. I completely went on different path. Nice explanation I Kept min element in bag 3 and maximum element in another bag 2 , and rest all other elements in bag 1 Should have created more examples and tried out but trying out examples in paper, to find optimal answer itself is tiring for this question
@competitivecoding-newtonsc96012 жыл бұрын
Questions like these are quite luck oriented. Either you solve it in 10 minutes or take the whole contest for it.
@aaravgautam72632 жыл бұрын
yep today second option fitted for me😁
@saumyaranjan92562 жыл бұрын
yup, went with the same exact approach for this question and got it wrong.
@KaifKhan-gs7lw2 жыл бұрын
I tried the same thing🙃
@devanshgoel34332 жыл бұрын
I also tried the same approach as told by @revanth.
@praveenkpandey346 ай бұрын
amazing ! editorial , i mean it is way way better then actual editorial ..
@nikhildixit5687 Жыл бұрын
such a nice explanation lot of hard work by you, kudos!!!!!!!!
@leoara80192 жыл бұрын
thank you soo much greetings from Syria
@competitivecoding-newtonsc96012 жыл бұрын
No worries 🤠
@rohitsatpute95782 жыл бұрын
What a explanation!! Hats off
@kamranali43582 жыл бұрын
Can you please explain observation 1?
@competitivecoding-newtonsc96012 жыл бұрын
It just means that in the optimal answer, array will be broken into contiguous segments.
@priovag26322 жыл бұрын
Can I ask you why do we use the max for abs(arr[i]-arr[i+1) and abs(arr[i]-arr[i-1]), instead of min? The taker always try to get the closest so the taker can reduce the total score, right? Thank you.
@sudhanshu98312 жыл бұрын
We are assigning the weights in bags. So we'll assign them in a way we get the maximum answer. After that, the taker may choose any way and he'll get the minimum answer as given
@competitivecoding-newtonsc96012 жыл бұрын
This depends on how we assign bags, not on how the taker chooses bricks. So we take max, as it's upto us to assign maximum score.
@ayyappaswamy82202 жыл бұрын
In the first example if we pick bricks whose weights are 1 5 2 the answer would be 7 which is greater than 6. Why shouldn't we pick 1 5 2
@competitivecoding-newtonsc96012 жыл бұрын
Because the person picking the bricks, wants to minimise the score. He will pick the bricks from the given bags such that score is minimum. We want to create these bags such that this minimum score is as big as possible.
@criticcell2 жыл бұрын
Hey, I was just wondering about this. I see a lot of channels with the name of Newton School in it. Do they select creators or is this an opportunity open to all. Please specify the details on how someone can be a part of it.
@competitivecoding-newtonsc96012 жыл бұрын
They select creators. I don't know to apply for it though. A senior referred me for it.
@rohitn63332 жыл бұрын
Thanks for this wonderful solution sir could you upload D also
@competitivecoding-newtonsc96012 жыл бұрын
Already uploaded
@rohitn63332 жыл бұрын
@@competitivecoding-newtonsc9601 thank you sir, please continue uploading these solutions. These are very helpful sir Your way of explaining is very good sir
@xolo26172 жыл бұрын
is it type of book allocation problem , where we use binary search ?
@competitivecoding-newtonsc96012 жыл бұрын
Ahh not sure, how you can use binary search on this.
@kamranali43582 жыл бұрын
What could be rating of this problem?
@competitivecoding-newtonsc96012 жыл бұрын
1500
@kumaramit04-q6c2 жыл бұрын
I also used the same approach.
@competitivecoding-newtonsc96012 жыл бұрын
Nice ;)
@CosmoVision12 жыл бұрын
Good explanation. However, I put the max element in bag 2, min element in bag 3 and all elements that are left in bag 1 but this solution fails on test 2 and I can't figure out why, could you give an example where this solution fails?
@competitivecoding-newtonsc96012 жыл бұрын
Try 1,2,7,10,10
@sfg80511 ай бұрын
please tell me whats wrong in my approach ll n; cin >> n; vl arr(n); setst; loop(i,n){ cin>>arr[i]; st.insert(arr[i]); } ll ans=0; sort(all(arr)); ans+=abs(arr[0]-arr[n-1]); ll maxi=1e9; ll maxi2=1e9; for(int i=1;i
@satvikdixit2 жыл бұрын
Upload D and E as well plz
@competitivecoding-newtonsc96012 жыл бұрын
Will work on it.
@gurmansingh18782 жыл бұрын
Bro can you kindly tell why this code fails...the logic we applied to bag3 (i.e it's size == 1) we can also minimize the size of bag2 == 1 ( we tend to reduce a3) and remaining elements in bag1 void solve() { int n; cin >> n; vll wt(n); for(auto &i : wt) cin >> i; sort(all(wt)); ll ans = (wt.back() - wt.front()); ll m1 = N, m2 = N; for(int i = 1; i < n-1; ++i) { m1 = min(wt[i] - wt.front(), m1); m2 = min(wt.back() - wt[i], m2); debug(m1, m2); } ans += max(m1, m2); cout
@competitivecoding-newtonsc96012 жыл бұрын
How are you placing the bags?
@gurmansingh18782 жыл бұрын
@@competitivecoding-newtonsc9601 by taking ..if bag2 as min then bag3 as max vice-versa ..and just keeping all reamining values i.e from index i = 1 ...n-1 in bag1
@competitivecoding-newtonsc96012 жыл бұрын
What about case like 1 1 2 3 3 ? Isn't it optimal to assign 1 1 or 3 3 to bag 2?
@gurmansingh18782 жыл бұрын
@@competitivecoding-newtonsc9601 Thanks a lot bro...I understand clearly