Advertisement
rjlth

Untitled

Aug 15th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. int n, l, r, a[200020];
  2.  
  3. int main()
  4. {
  5. #ifndef ONLINE_JUDGE
  6. freopen("input.txt","rt",stdin);
  7. freopen("output.txt","wt",stdout);
  8. #endif
  9. cin>>n;
  10. for (int i=0; i<n; i++) scanf("%d", a+i);
  11. sort(a, a+n);
  12. cout<<a[n-1]-a[0]<<" ";
  13. l=upper_bound(a, a+n, a[0])-a;
  14. r=lower_bound(a, a+n, a[n-1])-a;
  15. r=n-r;
  16. //cout<<"\n"<<l<<" "<<r;
  17. if (a[0]!=a[n-1])
  18. cout<<l*1ll*r; else
  19. cout<<(n*1ll*(n-1))/2;
  20. return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement