140412025-01-09 17:53:37zhuyiInverziócpp17Compilation error
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
    int n; cin >> n;
    vector <int> S(n+1);
    for(int i = 1; i <= n; i++)
    {
        int s; cin >> s;
        S[s] = i;
    }
    int maxi = 0;
    int ans1 = 0; int ans2 = 0;
    int cur = S[1];
    for(int i = 2; i <= n; i++)
    {
        if(S[i] > cur) cur = S[i];
        else if(cur - S[i] > maxi)
            {
                maxi = cur - S[1];

                ans1 = cur;
                ans2 = S[i];

            }
        }
    }
    if(maxi == 0){
        cout << -1;
        return 0;
    }
    cout << ans2 << " " << ans1;
    return 0;
}
Compilation error
open /var/local/lib/isolate/426/box/a.out: no such file or directory
main.cpp:30:5: error: expected unqualified-id before 'if'
   30 |     if(maxi == 0){
      |     ^~
main.cpp:34:5: error: 'cout' does not name a type
   34 |     cout << ans2 << " " << ans1;
      |     ^~~~
main.cpp:35:5: error: expected unqualified-id before 'return'
   35 |     return 0;
      |     ^~~~~~
main.cpp:36:1: error: expected declaration before '}' token
   36 | }
      | ^