Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- using namespace std;
- typedef long long ll;
- int main(){
- ios_base::sync_with_stdio(false);
- int n;
- cin >> n;
- vector<int> a(n);
- for(int i = 0; i < n; ++i){ cin >> a[i]; }
- const int min_value = *min_element(a.begin(), a.end());
- const int max_value = *max_element(a.begin(), a.end());
- const int min_count = count(a.begin(), a.end(), min_value);
- const int max_count = count(a.begin(), a.end(), max_value);
- ll answer = 0;
- if(min_value == max_value){
- answer = static_cast<ll>(min_count) * (min_count - 1) / 2;
- }else{
- answer = static_cast<ll>(min_count) * max_count;
- }
- cout << max_value - min_value << " " << answer << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement