Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include <algorithm>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- long long diff;
- long long arr[n];
- for(int i=0; i<n; i++)
- {
- cin >> arr[i];
- }
- // for(int i=1; i<n; i++)
- // {
- // int minimumIndex=i;
- // while(minimumIndex>0 && arr[minimumIndex]<arr[minimumIndex-1])
- // {
- // long long temp = arr[minimumIndex-1];
- // arr[minimumIndex-1]=arr[minimumIndex];
- // arr[minimumIndex]=temp;
- // minimumIndex--;
- // }
- // }
- diff=abs(arr[0]-arr[n-1]);
- int minCounter=0;
- int maxCounter=n-1;
- int sameMinElement=1;
- int sameMaxElement=1;
- while(arr[minCounter]==arr[minCounter+1])
- {
- minCounter++;
- sameMinElement++;
- }
- while(arr[maxCounter]==arr[maxCounter-1])
- {
- maxCounter--;
- sameMaxElement++;
- }
- cout << diff << " "<<sameMaxElement*sameMinElement;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement