Untitled
unknown
c_cpp
a year ago
601 B
7
Indexable
#include <bits/stdc++.h>
using i64 = long long;
void solve() {
int n;
std::cin >> n;
std::vector<int> a(n);
for (int i = 0; i < n; i++) {
std::cin >> a[i];
}
auto it = std::min_element(a.begin(), a.end());
if (std::is_sorted(it, a.end())) {
std::cout << it - a.begin() << "\n";
} else {
std::cout << -1 << "\n";
}
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t;
std::cin >> t;
while (t--) {
solve();
}
return 0;
}Editor is loading...
Leave a Comment