题目大意:给你n个旅券,上面有开始时间l,结束时间r,和花费cost,要求选择两张时间不相交的旅券时间长度相加为x,且要求花费最少. 解题思路:看了大佬的才会写!其实和之前Codeforces 776C的写法有点像,遍历l,设以l为起始时间时长为time,看是否存在时长为x-time且与当前时段不相交的时间段,取最小值. 代码: #include<iostream> #include<cstdio> #include<algorithm> #include<vec…
D. Fedor and coupons time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output All our characters have hobbies. The same is true for Fedor. He enjoys shopping in the neighboring supermarket. The goo…
It's well known that the best way to distract from something is to do one's favourite thing. Job is such a thing for Leha. So the hacker began to work hard in order to get rid of boredom. It means that Leha began to hack computers all over the world.…
题意 给出一些闭区间(始末+代价),选取两段不重合区间使长度之和恰为x且代价最低 思路 相同持续时间的放在一个vector中,内部再对起始时间排序,从后向前扫获取对应起始时间的最优代价,存在minn中,对时间 i 从前向后扫,在对应的k-i中二分找第一个不重合的区间,其对应的minn加上 i 的cost即为出发时间为 i 时的最优解 代码 #include<bits/stdc++.h> using namespace std; int n, k; struct EVE{ int st,ed,v…
Hacker, pack your bags [题目链接]Hacker, pack your bags &题意: 有n条线段(n<=2e5) 每条线段有左端点li,右端点ri,价值cost(1 <= li <= ri <= 2e5, cost <= 1e9) 对于一个给定的x(x <= 2e5),寻找两个不相交的线段,使它们的长度和恰好为x,并且价值和最小 &题解: 只有2个线段,并且他们的和是定值x.但是还有另外一个条件,他们的区间不相交,这个我们可以…
C. Hacker, pack your bags! time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output It's well known that the best way to distract from something is to do one's favourite thing. Job is such a thing…
题目大意是给若干线段及其费用,每个线段权值即为其长度.要求找出两个不重合线段,令其权值和等于x且费用最少. 解法: 先分析一下题目,要处理不重合的问题,有重合的线段不能组合,其次这是一个选二问题,当枚举其中一条线段时,另一条合法线段的必要条件“权值”可以直接得出. 对于第一个问题,想到先对线段根据l进行排序,这样每次枚举一个线段的时候,如果在它的l之后有一个合法线段,我们只要标记一下x-LenNow,待枚举到那个合法线段的时候自然就判断出来了.如果在它之前有一个合法线段符合条件,根据刚刚的做法我…
C. Hacker, pack your bags!     It's well known that the best way to distract from something is to do one's favourite thing. Job is such a thing for Leha. So the hacker began to work hard in order to get rid of boredom. It means that Leha began to hac…
C. Hacker, pack your bags! time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output It's well known that the best way to distract from something is to do one's favourite thing. Job is such a thing…
题目链接:http://codeforces.com/contest/822/submission/28248100 题解:多维的可以先降一下维度sort一下可以而且这种区间类型的可以拆一下区间只要加一个标记就知道这是开始区间还是结束区间具体看一下代码. #include <iostream> #include <cstring> #include <algorithm> #include <cstdio> #define inf 1000000000000…