Subordinates(贪心)】的更多相关文章

E. Subordinates time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are n workers in a company, each of them has a unique id from 1 to n. Exaclty one of them is a chief, his id is s. Each…
There are n workers in a company, each of them has a unique id from 1 to n. Exaclty one of them is a chief, his id is s. Each worker except the chief has exactly one immediate superior. There was a request to each of the workers to tell how how many…
从前往后扫,找到一出现次数为0的数,从后面找一个出现不为0的数转化而来.设置两指针l, r来处理. #include<cstdio> #include<iostream> #include<cstdlib> #include<cstring> #include<string> #include<algorithm> #include<map> #include<queue> #include<vector…
题目链接 http://codeforces.com/contest/729/problem/E 题意:给你n个人,主管id为s,然后给你n个id,每个id上对应一个数字表示比这个人大的有几个. 最后问你有几个人搞错了. 一道简单的贪心题先将比自己大有i个人的存起来然后倒着贪心讲后面的补上前面不足的.当主管搞错时要特殊考虑一下 拿样例举例 (1) 3 2 2 0 2 (上司数) 0 1 (个数)     1 0 2 2 这样显然不符合因为上司为1个的没有而上司为2个的却有2个,所以一定要吧补上一…
题目大意: 一共有N个员工,其中最高领导人是编号s的人,每个人都只有一个直接领导,每个人都说出了自己领导的个数,问最少有几个人撒谎了. 思路: 合理的贪心是该把排最后的数变成缺少的数字,然后继续判断. (不一定非要01234 可以011223) #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> #include<…
题目链接:http://codeforces.com/problemset/problem/729/E 既然每一个人都有一个顶头上司,考虑一个问题: 如果这些人中具有上司数目最多的人有$x$个上司,那么一定存在一些人,他们分别有$x-1,x-2...1$个上司. 首先如果$s$位置上的上司数目不为$0$,非$s$位置上的上司数目为$0$它们就是一定说错了话的. 问题转化为了:将合法的上司数目从小到大小排序,我们现在要这个序列的数字连续单调不降,并且相差不能为大于$1$. 有一人些已经说错了话,考…
链接: http://acm.sgu.ru/problem.php?contest=0&problem=195 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=26733#problem/E 195. New Year Bonus Grant time limit per test: 1.5 sec. memory limit per test: 65536 KB input: standard output: standard All…
1692: [Usaco2007 Dec]队列变换 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 1383  Solved: 582[Submit][Status][Discuss] Description FJ打算带他的N(1 <= N <= 30,000)头奶牛去参加一年一度的“全美农场主大奖赛”.在这场比赛中,每个参赛者都必须让他的奶牛排成一列,然后领她们从裁判席前依次走过. 今年,竞赛委员会在接受队伍报名时,采用了一种新的登记规则:他们把所…
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 15564    Accepted Submission(s): 6405 Problem Description There is a pile of n wooden sticks. The length and weight of each stick a…
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 56784    Accepted Submission(s): 19009 Problem Description FatMouse prepared M pounds of cat food, ready to trade with the cats g…