//好像读错题了,而且各种坑爹的错误

-。-以前的代码,忘记这题目在讲什么了

Description

Pashmak decided to give Parmida a pair of flowers from the garden. There are n flowers in the garden and the i-th of them has a beauty number bi. Parmida is a very strange girl so she doesn't want to have the two most beautiful flowers necessarily. She wants to have those pairs of flowers that their beauty difference is maximal possible!

Your task is to write a program which calculates two things:

The maximum beauty difference of flowers that Pashmak can give to Parmida.

The number of ways that Pashmak can pick the flowers. Two ways are considered different if and only if there is at least one flower that is chosen in the first way and not chosen in the second way.

Input

The first line of the input contains n(2 ≤ n ≤ 2·105). In the next line there are n space-separated integers b1, b2, ..., bn(1 ≤ bi ≤ 109).

Output

The only line of output should contain two integers. The maximum beauty difference and the number of ways this may happen, respectively.

Sample Input

Input

2

1 2

Output

1 1

Input

3

1 4 5

Output

4 1

Input

5

3 1 2 3 1

Output

2 4

Hint

In the third sample the maximum beauty difference is 2 and there are 4 ways to do this:

choosing the first and the second flowers;

choosing the first and the fifth flowers;

choosing the fourth and the second flowers;

choosing the fourth and the fifth flowers.

#include<stdio.h>#include<algorithm>using namespace std;int main(){int n,i;while(~scanf("%d",&n)){int a[200012];for(i=0;i<n;i++){scanf("%d",&a[i]);}sort(a,a+n);int max=a[n-1];int min=a[0];int count1=0;int count2=0;for(i=0;i<n;i++){if(a[i]==max)count1++;if(a[i]==min)count2++;}if(max==min)printf("0 %I64d\n",(__int64)n*(n-1)/2);elseprintf("%d %I64d\n",max-min,(__int64)count1*count2);}return 0;}

转载于:https://www.cnblogs.com/awsent/p/4267002.html

寒假CF- WA了不要怕!相关推荐

  1. (寒假CF)Choosing Symbol Pairs

    //我觉得这题好像跟我理解的不太一样啊T ^ T,有点郁闷 Description There is a given string S consisting of N symbols. Your ta ...

  2. 有点坎坷,却又有点感动。

    5.23 UPD:其实最近这段时间虽然打了不少农药,但也写了一些题,感觉就算不打游戏我也来不及写题解.接下来除了期末考试主要还是补容斥和dp方面的东西,以及点分治这个我一直理解不好的东西,应该会写一些 ...

  3. JavaScript--jquery.min.js文件

    1 /*! jQuery v1.12.3 | (c) jQuery Foundation | jquery.org/license*/ 2 !function(a,b){"object&qu ...

  4. 机器学习理论引导 电子版_机器学习理论篇1:机器学习的数学基础(2)

    本节主要就是讲述的机器学习的数学基础,提到数学基础,可能一眼就会是满眼的枯燥.没意思,但是成就英雄的路上注定了孤独,要想要真正的在学术上有所突破就必须挨得住寂寞,受得住孤独,才能真正的走进熟悉直到完全 ...

  5. SpringBoot开发常用技术这些你知道吗???

    初学SpringBoot,只浅在的学了,所以内容比较简单,代码可能比较多,因为现在我注重于用还没有研究其底层,所以看完本文章每一章节理解后,能自己敲一遍,明白其流程,实现功能便可,文中若有纰漏望指出ψ ...

  6. 2048小游戏(网页版)

    这是JS文件 ↓ /*这是JS文件*/ (function(window, document, $) {function Game2048(opt) {var prefix = opt.prefix, ...

  7. ajax实现聊天机器人(语音助手)完整源码

    实现思路:(1)点击发送按钮触发点击事件,进行非空判断,如果输入内容为空或空格,跳出弹窗"输入内容不能为空"(2)设置全局空数组用于存放用户和机器人的语言,为了进行区分,可在数组中 ...

  8. jquery-1.12.4.min.js(代码免费下载)

    jquery-1.12.4.min.js页面代码(创建一个js页面,把下面代码复制进去就成了一个jquery库)(找了一段时间,csdn里全是付费下载,有些地方也可以下,但很找,所以本人就无偿把自己在 ...

  9. 你付出多少,以后都会补给你

    昨天,突然收到我的论文老师发给我的qq消息,她说,寒假在家玩得愉快?这句话竟让我无从作答,因为放假之前她在带着我写论文,查文献,索资料,帮助我很多,但由于期末考试就暂时放了一段时间,放假后又忙着准备寒 ...

  10. CF 2022寒假练习

    CF 2022寒假练习 CF_2A Winner 链接 CF_2A Winner 题目大意 有一个游戏,由nnn个玩家参与,每一轮会有一个玩家获得sss点数.游戏最后一轮结束后,点数最多的玩家获胜.如 ...

最新文章

  1. django创建验证码
  2. 兼容性—IE6/7下带有overflow:hidden属性的父级元素包不住带有position:relative属性的子元素...
  3. tensorflow中的交叉熵损失
  4. python plot方法的使用_【python】matplotlib.pyplot入门
  5. 判断当前界面是该fragment_学不动也要学!探究Fragment延迟加载的前世今生
  6. 小型数据库_如果您从事“小型科学”工作,那么您是否正在利用数据存储库?
  7. Visual C++ 编译器选项 /MD、/ML、/MT、/LD
  8. jedis StreamEntryID参数解释
  9. html5饼图的制作方法,html5制作饼图
  10. c++注释快捷键_JAVA编程中你一定要掌握的“快捷键”
  11. 【python笔记】:python面向对象实现学生管理系统
  12. [转载] Python 内置函数 dir()
  13. python如何截长图_python+selenium实现长截图
  14. 电脑笔记本利用谷歌浏览器进行网页截长图滚动截图
  15. 2021年最新版裁判文书逆向
  16. git报错the remote end hung up unexpectedlyMiB解决方法
  17. EPICS IOC Shell
  18. HCIA基础课程 一
  19. 搭建Free NAS环境
  20. 音频编解码·格式篇(1)Wave PCM audio format(WAV)

热门文章

  1. oracle 10g
  2. Cassandra学习手册之一:Cassandra介绍
  3. KZWFoudation系列之Router的设计
  4. 操作系统级虚拟化概述
  5. item的常用类型上
  6. Spring的静态代理和动态代理
  7. 全民直播CTO张云龙:已全面迁移至阿里云
  8. LightOJ 1205 Palindromic Numbers
  9. JavaWeb:Tomcat下配置数据源连接数据库
  10. MySQL 5.1中IN查询不要用到NULL条件