Advertisement
schl

marsovci_v1

Mar 10th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. typedef struct{
  5.     int x, poz;
  6. }el;
  7.  
  8. int main(){
  9.     int n; cin >> n;
  10.     int arr[n];
  11.  
  12.     cin >> arr[0];
  13.     el smallest, biggest;
  14.  
  15.     smallest.poz = 0; smallest.x = arr[0];
  16.     biggest.poz = 0; biggest.x = arr[0];
  17.  
  18.     for(int i = 1; i < n; i++){
  19.         cin >> arr[i];
  20.         if(smallest.x > arr[i]){
  21.             smallest.x = arr[i];
  22.             smallest.poz = i;
  23.         }
  24.         else if(biggest.x <= arr[i]){
  25.             biggest.x = arr[i];
  26.             biggest.poz = i;
  27.         }
  28.     }
  29.  
  30.     int res = (biggest.poz + 1) * (n - smallest.poz);
  31.  
  32.     cout << res;
  33.  
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement