Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save KhaledElshamy/7234d3757d9787ae70c28be17fb169d6 to your computer and use it in GitHub Desktop.
Save KhaledElshamy/7234d3757d9787ae70c28be17fb169d6 to your computer and use it in GitHub Desktop.
B. Pashmak and Flowers-Codeforces Solution
// 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