Codeforces gym 100685 C. Cinderella 水题
C. Cinderella
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://codeforces.com/gym/100685/problem/C
Description
Cinderella is given a task by her Stepmother before she is allowed to go to the Ball. There are N (1 ≤ N ≤ 1000) bottles with water in the kitchen. Each bottle contains Li (0 ≤ Li ≤ 106) ounces of water and the maximum capacity of each is 109 ounces. To complete the task Cinderella has to pour the water between the bottles to fill them at equal measure.
Cinderella asks Fairy godmother to help her. At each turn Cinderella points out one of the bottles. This is the source bottle. Then she selects any number of other bottles and for each bottle specifies the amount of water to be poured from the source bottle to it. Then Fairy godmother performs the transfusion instantly.
Please calculate how many turns Cinderella needs to complete the Stepmother's task.
Input
The first line of input contains an integer number N (1 ≤ N ≤ 1000) — the total number of bottles.
On the next line integer numbers Li are contained (0 ≤ Li ≤ 106) — the initial amount of water contained in ith bottle.
Output
Output a single line with an integer S — the minimal number of turns Cinderella needs to complete her task.
Sample Input
3
5 7 7
Sample Output
2
HINT
题意
每一个回合可以选择一瓶水然后给其他杯子倒水,然后问你最少几个回合可以使得所有的杯子里面的水都一样
题解:
求一个平均数,然后大于平均数的就直接倒水就好了
代码
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 2000001
#define mod 1000000007
#define eps 1e-9
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//************************************************************************************** ll sum=;
ll a[maxn];
int main()
{
int n=read();
for(int i=;i<n;i++)
a[i]=read(),sum+=a[i];
ll kiss=sum/n;
int ans=;
for(int i=;i<n;i++)
if(a[i]>kiss)
ans++;
cout<<ans<<endl;
}
Codeforces gym 100685 C. Cinderella 水题的更多相关文章
- Codeforces Gym 100286G Giant Screen 水题
Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...
- Codeforces Gym 100431D Bubble Sort 水题乱搞
原题链接:http://codeforces.com/gym/100431/attachments/download/2421/20092010-winter-petrozavodsk-camp-an ...
- Codeforces GYM 100114 B. Island 水题
B. Island Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description O ...
- Codeforces gym 100685 A. Ariel 暴力
A. ArielTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/A Desc ...
- Codeforces gym 100685 F. Flood bfs
F. FloodTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/F Desc ...
- Codeforces gym 100685 E. Epic Fail of a Genie 贪心
E. Epic Fail of a GenieTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685 ...
- codeforces 577B B. Modulo Sum(水题)
题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #367 (Div. 2)---水题 | dp | 01字典树
A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...
- codeforces 696A Lorenzo Von Matterhorn 水题
这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽 ...
随机推荐
- java之URL类
Java的网络类可以让你通过网络或者远程连接来实现应用.而且,这个平台现在已经可 以对国际互联网以及URL资源进行访问了.Java的URL类可以让访问网络资源就像是访问你本地的文件夹一样方便快捷.我们 ...
- 【转】定时器、sigevent结构体详解
原文网址:http://blog.163.com/zheng_he_xiang/blog/static/18650532620116311020390/ 最强大的定时器接口来自POSIX时钟系列,其创 ...
- poj 4052(ac自动机)
题意:自己百度吧!! 分析:就是通过它的fail指针来找出它的子串就行了,这题其实不难的.这好像还是金华邀请赛的题哦! 代码实现: #include<cstdio> #include< ...
- C# Code for Downloading Stock Symbols z
http://www.jarloo.com/download-stock-symbols/ If your using C# you can easily get the XML data using ...
- UILabel 自适应大小
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStylealloc]init]; paragraphStyle.lineB ...
- 《Python基础教程(第二版)》学习笔记 -> 第十章 充电时刻 之 标准库
SYS sys这个模块让你能够访问与Python解释器联系紧密的变量和函数,下面是一些sys模块中重要的函数和变量: 函数和变量 描述 argv 命令行参数,包括脚本和名称 exit([arg]) ...
- XShell 屏幕锁定的恢复方法(Ctrl+Q)
操作XShell过程中很多时间大家会习惯性的按Ctrl+S进行保存. Ctrl+S在XShell的作用是屏幕锁定,很多朋友会无法操作,会直接把窗口关闭. 解决方法: 快捷键 Ctrl+Q 即能完成解锁 ...
- 利用原生JavaScript获取样式的方式小结
来源:http://www.ido321.com/930.html ps:是获取样式,不是设置样式.若没有给元素设置样式值,则返回浏览器给予的默认值.(论坛整理) 1.element.style:只能 ...
- Python闭包与javascript闭包比较
实例一 python def line_conf(): def line(x): return 2*x+1 print(line(5)) # within the scope line_con ...
- CUDA 进阶学习
CUDA基本概念 CUDA网格限制 1.2CPU和GPU的设计区别 2.1CUDA-Thread 2.2CUDA-Memory(存储)和bank-conflict 2.3CUDA矩阵乘法 3.1 全局 ...