-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path459B.cpp
More file actions
35 lines (33 loc) · 727 Bytes
/
Copy path459B.cpp
File metadata and controls
35 lines (33 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(int i = 0;i<n;i++)
void solve() {
int n; cin >> n;
int minl, maxl;
int temp; cin >> temp;
maxl = temp;
minl = temp;
map<int,int> freq;
freq[temp]++;
REP(i, n-1){
cin >> temp;
minl = min(temp, minl);
maxl = max(temp, maxl);
freq[temp]++;
}
ll mults;
if(maxl == minl) mults = 1LL*freq[maxl]*(freq[maxl]-1)/2;
else mults = 1LL*freq[maxl]*freq[minl];
cout << maxl - minl << " " << mults;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int test = 1;
// cin >> test;
while(test--){
solve();
}
return 0;
}