Getting WA Can someone help me find what is the mistake I’ve done

here is the link to my solution

https://www.codechef.com/viewsolution/33069928

Thank you all

Getting WA Can someone help me find what is the mistake I’ve done

here is the link to my solution

https://www.codechef.com/viewsolution/33069928

Thank you all

why are you writing a program of 45 lines?? its a simple program #include

#include <bits/stdc++.h>

using namespace std;

int main() {

long long n,b,l,temp,i,j,k ;

cin>>n;

long long c[n];

for (i=0;i<n;i++)

{cin>>c[i];}

k=sizeof ©/sizeof (c [0]);

sort(c,c+k);

long long d[n];

for (j=0;j<n;j++)

{

d [j]=c[j]*(n-j);

```
}
l=sizeof (d)/sizeof (d[0]);
sort (d,d+l);
cout << d[n-1];
```

}

I have done this approach

But also wanted to find out what is the problem with above code as well

thank youu

Try tc-

5

3 4 5 6 7

You will know your mistake. In binary search your first condition will always be true. So,you are considering answer will be in second half always.