D's intution 1. If Array is non decreasing then we know first value is minimum and last value is maximum and you if you perform any operation then this will lead to increase in difference between minimum and maximum value 2. make all the non increasing subarray as non decreasing 3. for example 1 3 can't be changed as its non decreasing, but 3 1 can became 2 2, by make any non increasing array as all equal it will make sure that minimum and maximum values are as near as possible 4. Conclusion in non decreasing array minimum is first and maximum is last, and this is the best option possible but in non increasing array you can make all the elements as equal , thus (prefix / cnt) works
@@hunter-bf4ek thanks, start practicing questions rating wise like start from 1200 then do atleast 40, 50 questions of same rating, then increase the rating and repeat, and don't skip any contest
last figher will always win, it can't be defeated, to make it as large as possible make sure 2nd last element is as small as possible , to make 2nd last element , smallest just subtract all the elements form 0...n-3 from 2nd last element and then subtract that number from last one
D's intution
1. If Array is non decreasing then we know first value is minimum and last value is maximum and you if you perform any operation then this will lead to increase in difference between minimum and maximum value
2. make all the non increasing subarray as non decreasing
3. for example 1 3 can't be changed as its non decreasing, but 3 1 can became 2 2, by make any non increasing array as all equal it will make sure that minimum and maximum values are as near as possible
4. Conclusion
in non decreasing array minimum is first and maximum is last, and this is the best option possible
but in non increasing array you can make all the elements as equal , thus (prefix / cnt) works
Can you give prove for D that how how both max and min be occur simultaneously for some sequence of operation??
u can check the comment I have explained D
nice exlplanation!! can you suggest a way to practice efficiently (stuck in pupil )
@@hunter-bf4ek thanks,
start practicing questions rating wise like start from 1200 then do atleast 40, 50 questions of same rating, then increase the rating and repeat,
and don't skip any contest
C solution:
void solve(){
int n;
cin>>n;
if(n == 1){
int x = -1;
int num = 1;
while(x != 1){
num = 1-num;
cout
What is problem b says?
Dont understood your explanation.
Can you Simply elaborate plz
last figher will always win, it can't be defeated, to make it as large as possible make sure 2nd last element is as small as possible , to make 2nd last element , smallest just subtract all the elements form 0...n-3 from 2nd last element and then subtract that number from last one
first one here to comment.
@@mridu299 ♥️