Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
451 B
0
Indexable
Never
#include <iostream>
using namespace std;
int main() {
	int a, b, c, d, aa,bb,cc,dd,now,g;
	g = 0;
	cin >> a;
	aa = 101;
	bb = 0;
	cc = 0;
	dd = 0;
	int mas[100];
	for (int i = 0; i < a; i++) {
		cin >> d;
		mas[i] = d;
		if (d <= aa) {
			aa = d;
			bb = i;
		}
		if (d > cc) {
			cc = d;
			dd = i;
		}
	}
	if (bb + 1 == a && dd == 0) cout << 0;
	else if (bb > dd) cout << a - (bb+1) + dd;
	else cout << a - (bb+1) + dd-1;
}