Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- typedef struct{
- int x, poz;
- }el;
- int main(){
- int n; cin >> n;
- int arr[n];
- cin >> arr[0];
- el smallest, biggest;
- smallest.poz = 0; smallest.x = arr[0];
- biggest.poz = 0; biggest.x = arr[0];
- for(int i = 1; i < n; i++){
- cin >> arr[i];
- if(smallest.x > arr[i]){
- smallest.x = arr[i];
- smallest.poz = i;
- }
- else if(biggest.x <= arr[i]){
- biggest.x = arr[i];
- biggest.poz = i;
- }
- }
- int res = (biggest.poz + 1) * (n - smallest.poz);
- cout << res;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement