what is wrong in this or may be i didn’t understand the question compeletly??
using namespace std;
long long arr;
1.Size of array is 1e8 , which will give rte.
2.logic is wrong.
1 2 3 4 5
5 5 5 5 5
2 3 4 5 5
It is still unclear to me why your example should output 2 3 4 5 5. The statement presumes that any student should have a higher or equal mark than some other student after him. In your case, isn’t the first student with only 2 marks breaking this rule (as the one after him have 3, 4 or 5 marks)?
Also, why isn’t 5 5 5 5 5 a valid answer? It doesn’t state that we should minimize the sum of differences between the old marks and new marks.
Can you provide a better insight on this problem?