Created
March 10, 2017 08:04
-
-
Save KhaledElshamy/7234d3757d9787ae70c28be17fb169d6 to your computer and use it in GitHub Desktop.
B. Pashmak and Flowers-Codeforces Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// working.cpp by Bill Weinman <http://bw.org/> | |
#include <bits/stdc++.h> | |
using namespace std; | |
int main() | |
{ | |
long long n,b,min=0,max=pow(10,9),num1,num2,count1=0,count2=0; | |
cin>>n; | |
for(int i=0;i<n;i++) | |
{ | |
cin>>b; | |
if(b==max) | |
count1++; | |
if(b<max) | |
{ | |
max=b; | |
count1=1; | |
} | |
if(b==min) | |
count2++; | |
if(b>min) | |
{ | |
min=b; | |
count2=1; | |
} | |
} | |
cout<<min-max<<" "<<((count1==count2&&max==min)?count1*(count1-1)/2:(count1*count2))<<endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment