Codeforces 853A Planning】的更多相关文章

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…
题意 给出飞机单位晚点时间代价和原定起飞时间,现在前k分钟不能起飞,求付出的最小代价和起飞顺序 思路 构造两个优先队列q1,q2,q1按时间顺序,q2按代价顺序,初始将所有飞机入q1,将时间在k前的飞机从q1加入q2,然后按时间顺序取出q1加入q2,同时从q2取出代价最大的加入答案 代码 #include<bits/stdc++.h> using namespace std; inline int read(){ ,f= ; char ch = getchar(); ;ch = getchar…
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…
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,…
题目地址:http://codeforces.com/problemset/problem/853/A 题目大意: 本来安排了 n 架飞机,每架飞机有 ci 的重要度, 第 i 架飞机的起飞时间为 i ,而现在,在 k 时之前不能有任何飞机起飞,每个时间点只有1架飞机能起飞, 损失=(飞机现起飞时间-飞机原起飞时间)*该飞机的重要度. 现在要求你排一张时间表,要求每架飞机都只能在原起飞时间及以后起飞,且使损失最小. 题解: 贪心 暴力的数组模拟tle,o(≧口≦)o #include<bits/…
<题目链接> 题目大意: 表示有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…
贪心:让代价大的尽量移到靠前的位置. 做法:先让前k个数加进堆里,枚举k+1~n+k,每次把新元素加进堆后找到最大代价放在当前位置即可. #include<bits/stdc++.h> #define ll long long using namespace std; ; struct poi{int c,pos;}; priority_queue<poi>q; bool operator<(poi a,poi b){return a.c<b.c;} int n,k;…
Planning CodeForces - 854C 题意:有n架航班,第i架原先的时候是在第i分钟起飞的.现在前k分钟无法有飞机起飞,因此需要调整安排表,延后飞机起飞.仍然要求每一分钟只有一架飞机起飞.第i架飞机延误一分钟需要损失ci的钱.不能使飞机起飞的时间早于原先安排中起飞的时间.求如何安排新安排表使损失钱数最少. 方法: 显然,如果在第i分钟有一些飞机延误,那么一架飞机的c值越大,这一分钟产生的损失也越大,而使这一分钟产生的损失尽可能的小并不会导致接下来时间产生的损失增大.因此应当每一分…
已经是水到一定程度了QAQ- Code: #include<cstdio> #include<algorithm> #include<cstring> using namespace std; const int maxn = 105; int tp[maxn], idx[maxn], n,m, spare[maxn], cnt; bool cmp(int i,int j) { return i > j;} inline bool check(int val) {…
[链接]h在这里写链接 [题意] 让你确定ti,使得∑(ti-i)*gi最小,其中ti∈[k+1..k+n],且每个ti都不能一样. 且ti>=i必须成立. [题解] 分解一下成为∑ti*gi - ∑i*gi; 发现右边是定值. 左边,只要让大的gi分到尽量小的ti就好. 写个set,然后lower_bound一下. [错的次数] 0 [反思] 在这了写反思 [代码] #include <cstdio> #include <iostream> #include <alg…