#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
int a[110];
int main() {
int n;
int ans = 0;
int maxh = 0, minh = 1000000;
cin >> n;
for(int i = 1; i <= n; ++i) {
cin >> a[i];
if(maxh < a[i]) {
maxh = a[i];
}
if(minh > a[i]) {
minh = a[i];
}
}
int id1 = -1, id2 = -1;
for(int i = 1, j = n; i <= n; ++i, --j) {
if(a[i] == maxh && id1 == -1) {
id1 = i;
}
if(a[j] == minh && id2 == -1) {
id2 = j;
}
}
if(id1 < id2) {
ans = id1 - 1 + n - id2;
} else {
ans = id1 - 1 + n - id2 - 1;
}
cout << ans << endl;
return 0;
}
144A - Arrival of the General
最新推荐文章于 2019-05-10 15:10:32 发布