fork download
  1. # your code goes here#include "bits/stdc++.h"
  2. using namespace std;
  3.  
  4. int n;
  5. int a[100005];
  6. pair<int,int> p[100005];
  7. int maxi[100005];
  8.  
  9. int main()
  10. {
  11. scanf("%d",&n);
  12. for(int i = 1 ; i <= n ; i++)
  13. {
  14. scanf("%d",&a[i]);
  15. p[i]={a[i],i};
  16. }
  17. sort(p+1,p+n+1);
  18. maxi[n] = p[n].second;
  19. for(int i = n - 1 ; i >= 1 ; i--)
  20. {
  21. maxi[i] = max(maxi[i+1], p[i].second);
  22. }
  23. int ans = -1;
  24. for(int i = 1 ; i < n ; i++)
  25. {
  26. if(maxi[i+1]>p[i].second)
  27. ans=max(ans,maxi[i+1]-p[i].second);
  28. }
  29. cout<<ans;
  30. return 0;
  31. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/py_compile.py", line 117, in compile
    raise py_exc
py_compile.PyCompileError:   File "prog.py", line 2
    using namespace std;
                  ^
SyntaxError: invalid syntax

stdout
Standard output is empty