Distribution money

Accepts: 713
Submissions: 1881
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)
Problem Description

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.

Input

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

Output ID of the man who should be punished. If nobody should be punished,output -1.

Sample Input
3
1 1 2
4
2 1 4 3
Sample Output
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的更多相关文章

  1. 齐夫定律, Zipf's law,Zipfian distribution

    齐夫定律(英语:Zipf's law,IPA英语发音:/ˈzɪf/)是由哈佛大学的语言学家乔治·金斯利·齐夫(George Kingsley Zipf)于1949年发表的实验定律. 它可以表述为: 在 ...

  2. CloudSim4.0报错NoClassDefFoundError,Caused by: java.lang.ClassNotFoundException: org.apache.commons.math3.distribution.UniformRealDistribution

    今天下载了CloudSim 4.0的代码,运行其中自带的示例程序,结果有一部分运行错误: 原因是找不到org.apache.commons.math3.distribution.UniformReal ...

  3. Wishart distribution

    Introduction In statistics, the Wishart distribution is generalization to multiple dimensions of the ...

  4. distribution 中一直在运行 waitfor delay @strdelaytime 语句

    Replication 自动创建来一个 Job:Replication monitoring refresher for distribution,这个Agent执行一个sp: dbo.sp_repl ...

  5. Distribution2:Distribution Writer

    Distribution Writer 调用Statement Delivery 存储过程,将Publication的改变同步到Subscriber中.查看Publication Properties ...

  6. Distribution1:Distribution Reader

    在transactional replication中,在publication中执行了一个更新,例如:update table set col=? Where ?,如果table中含有大量的数据行, ...

  7. 设置Distribution clean up 每次删除Command的数量

    Replication Job “Distribution clean up: distribution” 默认设置是,每10minutes运行一次,每次删除2000个Command.这对于有1.9亿 ...

  8. Your account already has a valid iOS Distribution certificate!

    iOS 发布提交出现:Your account already has a valid iOS Distribution certificate!问题解决 转载的链接   http://www.jia ...

  9. Replication-Replication Distribution Subsystem: agent xxxxxx failed. Column names in each table must be unique

    最近遇到一个关于发布订阅(Replication)的奇葩问题,特此记录一下这个案例.我们一SQL SERVER数据库服务器出现大量告警.告警信息如下所示: DESCRIPTION: Replicati ...

  10. SQL Server删除distribution数据库

    在数据库服务器删除复制(发布订阅)后,如何删除掉数据库distribution呢?如果你通过SSMS工具去删除数据库distribution,你会发现根本没有删除选项. 下面介绍一下删除distrib ...

随机推荐

  1. Vue过渡:CSS过渡

    一 项目结构 二 App.vue <template> <div id="app"> <transition name="fade" ...

  2. Java Web项目启动执行顺序

    一. 1.启动一个WEB项目,WEB容器会先去读取它的配置文件web.xml,读取<context-param>和<listener>两个节点. 2.接着,容器创建一个Serv ...

  3. python数据类型补充

    四.元组 #为何要有元组,存放多个值,元组不可变,更多的是用来做查询 t=(1,[1,3],'sss',(1,2)) #t=tuple((1,[1,3],'sss',(1,2))) # print(t ...

  4. Expected one result (or null) to be returned by selectOne() 数据库结果集和java实例

    mybatis会根据查询的结果集初始化java实例. 如果是复杂类型,我们一般都会在mapper中做好映射. 1.所以如果查询到的是多个结果,那么对应的java类型也必须的集合类型.(result 为 ...

  5. Thinkphp在nginx设置同域名二级目录访问

    Thinkphp在nginx设置同域名二级目录访问,是因为最近弄一个小程序项目,要https,但是只有单个域名,不能通配域名,所有只好用二级目录,thinkphp二级目录访问要怎么设置呢 下面是ngi ...

  6. 监控软件之open-falcon

    一.open-falcon介绍 1)中文社区介绍 http://book.open-falcon.org/zh_0_2/intro/ 参照文档: https://www.cnblogs.com/LAl ...

  7. elasticsearch索引清理脚本shell

    es-index-clear.sh: #!/bin/bash#----------------------------------------------# Module: es-index-clea ...

  8. geometry_msgs的ros message 类型赋值

    test_custom_particles.cpp // // Created by gary on 2019/8/27. // #include <ros/ros.h> #include ...

  9. MySQL--17 配置binlog-server 及中间件

    目录 配置binlog-server MySQL中间件Atlas Atlas管理接口 配置binlog-server 修改mha配置文件 [root@mysql-db03 ~]# vim /etc/m ...

  10. (解决某些疑难杂症)Ubuntu16.04 + NVIDIA显卡驱动 + cuda10 + cudnn 安装教程

    一.NVIDIA显卡驱动 打开终端,输入: sudo nautilus 在新打开的文件夹中,进入以下路径(不要用命令行): 左下角点计算机,lib,modules 这时会有几个文件夹,对每个文件夹都进 ...