Distribution money
Distribution money
AFA want to distribution her money to somebody.She divide her money into n same parts.One who want to get the money can get more than one part.But if one man's money is more than the sum of all others'.He shoule be punished.Each one who get a part of money would write down his ID on that part.
There are multiply cases. For each case,there is a single integer n(1<=n<=1000) in first line. In second line,there are n integer a1,a2...an(0<=ai<10000)ai is the the ith man's ID.
Output ID of the man who should be punished. If nobody should be punished,output -1.
3
1 1 2
4
2 1 4 3
1
-1
题意:随意排队领薪金,如果一个人领的超过其他人的总和那么这个人将受到惩罚输出这个人的工号,如果没人领的薪金超过其他人的总和输出-1
总共薪金是n,某个人可能领x,那么其他人的总和就是n-x,如果x>n-x即x>n/2,那么这个人领的薪金就超过其他人输出这个人的工号
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <cstring> using namespace std; #define INF 0xfffffff
#define maxn 10005 int main()
{
int n, x, i, k;
int cnt[maxn]; while(scanf("%d", &n) != EOF)
{
memset(cnt, , sizeof(cnt));
k = -;
for(i = ; i <= n; i++)
{
scanf("%d", &x);
cnt[x]++;
} for(i = ; i<= ; i++)
{
if(cnt[i] > n/)
{
k = i;
break;
}
}
printf("%d\n", k);
}
return ;
}
Distribution money的更多相关文章
- 齐夫定律, Zipf's law,Zipfian distribution
齐夫定律(英语:Zipf's law,IPA英语发音:/ˈzɪf/)是由哈佛大学的语言学家乔治·金斯利·齐夫(George Kingsley Zipf)于1949年发表的实验定律. 它可以表述为: 在 ...
- CloudSim4.0报错NoClassDefFoundError,Caused by: java.lang.ClassNotFoundException: org.apache.commons.math3.distribution.UniformRealDistribution
今天下载了CloudSim 4.0的代码,运行其中自带的示例程序,结果有一部分运行错误: 原因是找不到org.apache.commons.math3.distribution.UniformReal ...
- Wishart distribution
Introduction In statistics, the Wishart distribution is generalization to multiple dimensions of the ...
- distribution 中一直在运行 waitfor delay @strdelaytime 语句
Replication 自动创建来一个 Job:Replication monitoring refresher for distribution,这个Agent执行一个sp: dbo.sp_repl ...
- Distribution2:Distribution Writer
Distribution Writer 调用Statement Delivery 存储过程,将Publication的改变同步到Subscriber中.查看Publication Properties ...
- Distribution1:Distribution Reader
在transactional replication中,在publication中执行了一个更新,例如:update table set col=? Where ?,如果table中含有大量的数据行, ...
- 设置Distribution clean up 每次删除Command的数量
Replication Job “Distribution clean up: distribution” 默认设置是,每10minutes运行一次,每次删除2000个Command.这对于有1.9亿 ...
- Your account already has a valid iOS Distribution certificate!
iOS 发布提交出现:Your account already has a valid iOS Distribution certificate!问题解决 转载的链接 http://www.jia ...
- Replication-Replication Distribution Subsystem: agent xxxxxx failed. Column names in each table must be unique
最近遇到一个关于发布订阅(Replication)的奇葩问题,特此记录一下这个案例.我们一SQL SERVER数据库服务器出现大量告警.告警信息如下所示: DESCRIPTION: Replicati ...
- SQL Server删除distribution数据库
在数据库服务器删除复制(发布订阅)后,如何删除掉数据库distribution呢?如果你通过SSMS工具去删除数据库distribution,你会发现根本没有删除选项. 下面介绍一下删除distrib ...
随机推荐
- Windows7下MongoDB的下载、安装与配置详解
一.Windows7下的运行库问题 虽然这个问题属于个例,但我觉得也有必要拿出来说说,保不齐你新装的系统就存在运行库没更新或者没装全的问题.出现这样的问题其实挺恼人的,具体表现就是系统经常会弹出警示框 ...
- DbWrench001--简介
DbWrench--简介 mac下载地址:http://www.dbwrench.com/ DbWrench 工具等价于powerdesigner 均为数据库原型设计工具 DbWrench 详细介绍 ...
- 记boost协程切换bug发现和分析
在分析了各大开源协程库实现后,最终选择参考boost.context的汇编实现,来写tbox的切换内核. 在这过程中,我对boost各个架构平台下的context切换,都进行了分析和测试. 在maco ...
- Spring学习(五)--构建Spring Web应用程序
一.Spring MVC起步 看过猫和老鼠的小伙伴都可以想象Tom猫所制作的捕鼠器:它的目标 是发送一个小钢球,让它经过一系列稀奇古怪的装置,最后触发捕鼠 器.小钢球穿过各种复杂的配件,从一个斜坡上滚 ...
- 702:Crossing River (贪心)
[题目描述] N个人过河,一次过去2个回来一个,给出每个人所需时间,问最小过河时间. [题目链接] http://noi.openjudge.cn/ch0406/702/ [算法] 一开始想样例是怎么 ...
- 故事版(storyBoard)-lllegal configuration connection cannot have a prototype objct as
今天下午做项目的时候.居然出了一个太不是问题的问题了,这个错误太低级了. lllegal configuration connection 'flagImg' cannot have a protot ...
- NavBarControl控件 2015-07-23 16:56 2人阅读 评论(0) 收藏
NavBarControl控件 1. 新建一个windows窗体应用程序项目 2. 在工具箱中的Navigation& Layout选项卡下找到NavBarControl, ...
- JS-01 书写规范
此部分内容整理自私教指导和自我体会:(持续更新...) 1.运算符左右两边留空格 (webstorm快捷键ctrl+alt+l): 2.判断值是否相等尽量用“===” 严格等于 : 3.编程中,可有可 ...
- java写文件UTF-8格式
String fileName = dir + File.separator + date + File.separator + (file.list().length + 1) + ".t ...
- linux性能相关的各个环节