Planning CodeForces - 854C】的更多相关文章

Planning CodeForces - 854C 题意:有n架航班,第i架原先的时候是在第i分钟起飞的.现在前k分钟无法有飞机起飞,因此需要调整安排表,延后飞机起飞.仍然要求每一分钟只有一架飞机起飞.第i架飞机延误一分钟需要损失ci的钱.不能使飞机起飞的时间早于原先安排中起飞的时间.求如何安排新安排表使损失钱数最少. 方法: 显然,如果在第i分钟有一些飞机延误,那么一架飞机的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 today,…
<题目链接> 题目大意: 表示有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;…
CodeForces 327A 题意:有n个数,都是0或1,然后必须执行一次操作,翻转一个区间,里面的数0变1,1变0,求最多1的数量 思路:最开始我写的最大字段和,后面好像写搓了,然后我又改成暴力,因为这个范围只有100,写n^3都没事,所以我们第一层枚举左区间,第二层枚举右区间,然后我们第三层记录左边1的数量,中间的0的数量,右边的1的数量即可 #include<cstdio> #include<cstring> #include<cmath> #include&l…
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…
已经是水到一定程度了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…
题意 给出飞机单位晚点时间代价和原定起飞时间,现在前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…
题目大意: 输入n,k,代表n列航班,初始始发实践为1,2,3分钟以此类推,然后输入n个整数分别代表延迟1分钟第i个航班损失多少钱,然后调整后的始发时间表是这样的,任何一辆航班的始发时间不能在他的初始始发实践之前而且满足k+1<=ti<=k+n,然后,让你输出最小的损失以及一次输出每辆航班的始发时间: 基本思路: 一开始我的思路是肯定是让每分钟损失最多的放在前面,然后由于还有限制条件所以,如果当前位置(时间)不能满足,那就向后找位置,但是这样是对于一个航班找时间,时间复杂度是n^2的,果断超时…
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 编号)及其美丽值,选取一条旅行路线,满足路线中两两城市美丽值之差等于编号之差,求所有旅行路线中美丽值的最大值. 思路: 美丽值与编号作差,差值为键,映射累加 . #include <bits/stdc++.h> using namespace std; int main() { int n;cin>>n; int b[n];for(int &i:b) cin>>i; map<int,long long> _m…
City Driving 题目连接: http://codeforces.com/gym/100015/attachments Description You recently started frequenting San Francisco in your free time and realized that driving in the city is a huge pain. There are only N locations in the city that interest yo…
Problem K. Kitchen Robot Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100610 Description Robots are becoming more and more popular. They are used nowadays not only in manufacturing plants, but also at home. One programmer wit…
http://codeforces.com/contest/489/problem/E E. Hiking time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A traveler is planning a water hike along the river. He noted the suitable rest points…
http://codeforces.com/problemset/problem/666/B 题意: 给定一张边权均为1的有向图,求四个不同的点A,B,C,D,使得dis[A][B]+dis[B][C]+dis[C][D]尽可能大.   预处理能到B的前3远,C能到的前3远 枚举B.C     #include<iostream> #include<cstring> #include<cstdio> #include<queue> using namespa…
A. Fraction 题目链接:http://codeforces.com/contest/854/problem/A 题目意思:给出一个数n,求两个数a+b=n,且a/b不可约分,如果存在多组满足条件的a和b,输出a/b最大的a和b. 题目思路:首先a+b=n,那么暴力枚举i和n-i,且gcd(i,n-i)==1,由于i越大是n-i越小,则a/b的值越大. 代码: //Author: xiaowuga #include <bits/stdc++.h> using namespace std…
After several latest reforms many tourists are planning to visit Berland, and Berland people understood that it's an opportunity to earn money and changed their jobs to attract tourists. Petya, for example, left the IT corporation he had been working…
B. World Tour 题目连接: http://www.codeforces.com/contest/666/problem/B Description A famous sculptor Cicasso goes to a world tour! Well, it is not actually a world-wide. But not everyone should have the opportunity to see works of sculptor, shouldn't he…
题目链接:Codeforces Round #433 (Div. 2) codeforces 854 A. Fraction[水] 题意:已知分子与分母的和,求分子小于分母的 最大的最简分数. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int gcd(int a,int b){return b?gcd(b…
A. Far Relative's Birthday Cake 题目连接: http://www.codeforces.com/contest/629/problem/A Description Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird! The cake is a…
CodeForces#536 A. Lunar New Year and Cross Counting Description: Lunar New Year is approaching, and you bought a matrix with lots of "crosses". This matrix \(M\) of size \(n \times n\) contains only 'X' and '.' (without quotes). The element in t…
今天是水题集啊.... A. Police Recruits time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The police department of your city has just started its journey. Initially, they don’t have any manpower. So,…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and…
我: Tech Leader 团队:团队成员分布在两个城市,我所在的城市包括我有4个成员,另外一个城市包括SM有7个成员.另外由于我们的BA离职了,我暂代IT 的PO 职位.PM和我在一个城市,但他不参于敏捷的运作里面. 迭代: 双周 主要会议: Grooming, Sprint Planning, Daily Standup Meeting, Sprint Review Meeting, Retrospective Meeting. 现在有名外部敏捷教练在带着我们实施敏捷,不过从sprint3…
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题.. 今天,我们来扒一下cf的题面! PS:本代码不是我原创 1. 必要的分析 1.1 页面的获取 一般情况CF的每一个 contest 是这样的: 对应的URL是:http://codeforces.com/contest/xxx 还有一个Complete problemset页面,它是这样的:…
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of bconsecutive cells. No cell can be part of two ships, however, the shi…
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's…
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is…
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概率是在正面,各个卡牌独立.求把所有卡牌来玩Nim游戏,先手必胜的概率. (⊙o⊙)-由于本人只会在word文档里写公式,所以本博客是图片格式的. Code #include <cstdio> #include <cstring> #include <algorithm> u…