C. Planning(贪心)】的更多相关文章

题面: 传送门 思路: 一眼看得,这是贪心[雾] 实际上,我们要求的答案就是sigma(ci*(ti-i))(i=1~n),这其中sigma(ci*i)是确定的 那么我们就要最小化sigma(ci*ti) 所以在新的每一秒,就把这一秒开始可以起飞的飞机中,cost最大的那一个拿出来,让他起飞就可以了 证明: 设最大的为m,我们取得另一个为n 那么n*ti+m*(ti+1) >= n*(ti+1)+m*ti 所以取m最好 这个过程用堆实现,懒得手打了,就用了priority_queue Code:…
链接 : http://codeforces.com/contest/854/problem/C 题意 : 有 n 架飞机需要分别在 1~n 秒后起飞,允许起飞的时间是从 k 秒后开始,给出每一架飞机拖延一秒的花费c[1]~c[n],问你如何安排飞机的起飞次序能够使得花费最小? 分析 : 需要安排的时间段为 k+1 ~ k+n ,贪心的策略是按这个顺序每一次选择花费最小  并且  不早于飞机规定的起飞时间的飞机区起飞必然能得到最优方案,因此我们可以构造一个优先队列每一次将待选飞机存放进去按照花费…
Helen works in Metropolis airport. She is responsible for creating a departure schedule. There are n flights that must depart today, the i-th of them is planned to depart at the i-th minute of the day. Metropolis airport is the main transport hub of…
题目大意: 输入n,k,代表n列航班,初始始发实践为1,2,3分钟以此类推,然后输入n个整数分别代表延迟1分钟第i个航班损失多少钱,然后调整后的始发时间表是这样的,任何一辆航班的始发时间不能在他的初始始发实践之前而且满足k+1<=ti<=k+n,然后,让你输出最小的损失以及一次输出每辆航班的始发时间: 基本思路: 一开始我的思路是肯定是让每分钟损失最多的放在前面,然后由于还有限制条件所以,如果当前位置(时间)不能满足,那就向后找位置,但是这样是对于一个航班找时间,时间复杂度是n^2的,果断超时…
A. Fraction 暴力遍历1-1000,取组成的真分数比值最大且分子分母gcd为1时更新答案 代码: #include <stdio.h> #include <algorithm> #include <cstdlib> #include <cstring> #include <bitset> #include <string> #include <stack> #include <cmath> #incl…
Planning time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output Helen works in Metropolis airport. She is responsible for creating a departure schedule. There are n flights that must depart today,…
C. Planning time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output Helen works in Metropolis airport. She is responsible for creating a departure schedule. There are n flights that must depart tod…
B - Planning 这个题目我知道要贪心,也知道怎么贪,但是写不出来,感觉自己好菜. 这个题目要用优先队列维护. 题目大意是飞机延误,不同的飞机每次延误一分钟,它的代价不同,然后问,怎么安排才能使飞机延误的代价最小, 唯一的限制就是飞机只能往后延误,不能提前. 然后看了网上的题解,首先我们把 1~ k 时候起飞的飞机直接放入优先队列,队列按照代价从大到小排序, 然后再考虑k+1~n的飞机,每次放入一架飞机,我们就可以求出一架在这个时刻最优的飞机. 为什么这么贪心是对的呢,首先如果前面的飞机…
Helen works in Metropolis airport. She is responsible for creating a departure schedule. There are n flights that must depart today, the i-th of them is planned to depart at the i-th minute of the day. Metropolis airport is the main transport hub of…
<题目链接> 题目大意: 表示有n架飞机本需要在[1,n]时间内起飞,一分钟只能飞一架.但是现在[1,k]时间内并不能起飞,只能在[k+1,k+n]内起飞.ci序号为i的飞机起飞延误一分钟的costi.每个飞机起飞时间不能比原定时间早,请安排一个起飞顺序,求最小的cost和. 解题分析: 贪心策略证明:转载于>>>设序号为i的飞机起飞时间为di,则cost=∑(di-i)*cj=∑di*cj-∑j*cj.显然后一项为常数,而{di-k}为[1,n]的一个排列, 所以只要使ci…