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 ...
随机推荐
- 【题解】4879. 【NOIP2016提高A组集训第11场11.9】少女觉
Description 在幽暗的地灵殿中,居住着一位少女,名为古明地觉.据说,从来没有人敢踏入过那座地灵殿,因为人们恐惧于觉一族拥有的能力——读心.掌控人心者,可控天下. 咳咳.人的记忆可以被描述为一 ...
- 求bit中1的个数有几种做法
原文 求bit中1的个数有几种做法: - x & (x - 1) - Hamming weight的经典求法,基于树状累加:http://en.wikipedia.org/wiki/Hammi ...
- Spring-Cloud-Alibaba-Nacos 目录
Spring-Cloud-Alibaba-Nacos 目录 学习资料 Nacos 官网(https://nacos.io/zh-cn/docs/what-is-nacos.html) Nacos 程序 ...
- ES6 find 和 filter 的区别
ES6 find 和 filter 的区别 : 遇到个功能是要分类就想说在前端过滤,不要从查数据库的时候过滤了.然后就想说除了filter还有啥好用的 发现有个find,测试一番之后发现 const ...
- C# 引用类型的深度拷贝帮助类
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Lin ...
- SQL server 连接 查询
在sql server中,我们经常能用到连接,今天总结一下连接的基础知识.连接的分类: 交叉连接CROSS JOIN 内连接INNER JOIN 外连接{左外连接LEFT [OUTER] JOIN : ...
- 为什么需要在 React 类组件中为事件处理程序绑定this?
https://juejin.im/post/5afa6e2f6fb9a07aa2137f51 事件绑定作为回调函数参数传递给函数,丢失其上下文,执行的是默认绑定,不是隐式绑定 类声明和类表达式的主体 ...
- JS变量连续赋值
下面就是这个经典案例: var a = {n: 1}; var b = a; a.x = a = {n: 2}; console.log(a);console.log(b); console.log( ...
- JS中 [] == ![]结果为true,而 {} == !{}却为false
为什么? 先转换再比较 (==) 仅比较而不转换 (===) ==转换规则? ==比较运算符会先转换操作数(强制转换),然后再进行比较 ①如果有一个操作数是布尔值,则在比较相等性之前 ...
- Codeforces Round #394 (Div. 2) - B
题目链接:http://codeforces.com/contest/761/problem/B 题意:给定一个环形跑道.里面有n个障碍,跑道长度为L.然后有两个人在两个起点(起点可能相同),每个人都 ...