Binary search- Euron Problem. i am tle for this code.can anyone suggest any optimisation?

#include
using namespace std;

int main() {
int n;
cin>>n;
long a[n];
for(int i=0;i<n;i++)
cin>>a[i];
int cnt=0;
for(int i=n-1;i>0;i–)
{ for(int j=i-1;j>=0;j–)

    {if(a[j]>a[i])
        cnt++;
    }
}
cout<<cnt<<endl;
// your code goes here
return 0;

}

Please Format your code..
To solve it quickly, you can use policy based data structures.

1 Like

Also what everule1 said… Format the code

1 Like

thanks a lot :slight_smile: can you please guide more about formatting?

Use ``` this symbol at start of code and at the end

1 Like

@shreyaa04 You might wanna read/bookmark the following articles, which will help you to format and write better next time on the Code-Chef DIscuss platform.

  1. Good practice for asking help - #6 by ssjgz
  2. [Tutorial] CoLoR format the Code!
1 Like