fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int N;
  6.  
  7. cin >> N;
  8.  
  9. vector <int> A(N+1);
  10. bool answer = false;
  11.  
  12. for(int i=1; i<=N; i++){
  13. cin >> A.at(i);
  14. }
  15.  
  16. for(int i=1; i<=N; i++){
  17. int X;
  18. answer = false;
  19. for(int j=i-1; j>=1; j--){
  20. if(A.at(j)>A.at(i)){
  21. answer = true;
  22. X = j;
  23. break;
  24. }
  25. }
  26. if(answer){
  27. cout << X << endl;
  28. }else{
  29. cout << -1 << endl;
  30. }
  31. }
  32. // your code goes here
  33. return 0;
  34. }
Success #stdin #stdout 0.01s 5320KB
stdin
4
4 3 2 5
stdout
-1
1
2
-1