Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define _test int _TEST; cin>>_TEST; while(_TEST--)
- int main()
- {
- _test
- {
- int n;
- cin>>n;
- vector<ll int> a(n);
- for(auto &e: a) cin>>e;
- int mmin = *min_element(a.begin(), a.end());
- int pos = -1;
- for(int i=0; i<n; i++)
- {
- if(a[i] == mmin)
- {
- pos = i;
- break;
- }
- }
- if(pos==n-1 || is_sorted(a.begin()+pos, a.end()))
- cout<<pos<<"\n";
- else
- cout<<-1<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment