http://acm.timus.ru/problem.aspx?space=1&num=1203 按照结束时间为主,开始时间为辅排序,那么对于任意结束时间t,在此之前结束的任务都已经被处理,从这个时间开始的任务都正要被处理, 因为t<=3e5,可以用简单dp解决 #include <cstdio> #include <algorithm> using namespace std; const int maxn=1e5+5; int n; typedef pair&l…
1203. Scientific Conference Time limit: 1.0 second Memory limit: 64 MB Functioning of a scientific conference is usually divided into several simultaneous sections. For example, there may be a section on parallel computing, a section on visualization…
Scientific Conference 之前一直在刷计算几何,邀请赛连计算几何的毛都买见着,暑假这一段时间就做多校.补多校的题目.刷一下一直薄弱的DP.多校假设有计算几何一定要干掉-.- 题意:给你N个报告会的開始时间跟结束时间.问你做多能够听几场报告会.要求报告会之间至少间隔为1. 思路:事实上是个活动安排问题.能够用贪心也能够用DP,贪心写起来会比較简单一些.由于练习DP,所以又用DP写了一遍. 贪心的话就是一个非常easy的活动选择问题,从结束时间入手,找每次的最优选择. 贪心: st…
题目:click here 分明就是贪心怎么会在dp的专题 #include <bits/stdc++.h> using namespace std; typedef unsigned long long ll; const int INF = 0x3f3f3f3f; ; struct Node { int F, S; bool operator < ( const Node x ) const { return S < x.S; } } p[M]; int n; int main…
http://acm.timus.ru/problem.aspx?space=1&num=1203 #include <cstdio> #include <cstring> #include <algorithm> #define maxn 400000 using namespace std; struct node { int s,e; bool operator <(const node &a)const { return ((e<a.…
题目链接 本来觉得这不是经典的贪心吗..果断水一次,wa了,看了看discuss,发现貌似不好水,土土的DP了一下,复杂度很高了,又T了...然后想想单调队列,二分什么的...不好往上加,直接搞了标记数组flag,暴力从大到小,遍历寻找,然后就过了...这算是优化吗,瞎搞... #include <cstring> #include <cstdio> #include <string> #include <iostream> #include <alg…
http://acm.timus.ru/problem.aspx?space=1&num=1009 题意:将一个n位数转化为合法的K进制数,有多少种情况.合法的K进制数即不含前导0,且任意两个0都不相邻. 思路:每一位的情况都分为:小于K且不等于0的情况或等于0的情况,每一位的选择都有前一位决定.dp[i][0]表示第i位为0的情况,dp[i][1]表示第i位不为0的情况,则 dp[i][0] = dp[i-1][1],dp[i][1] = (dp[i-1][1]+dp[i-1][0])*(k-…
题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1903 题意 一棵树,根上有VOD站,要求任意叶节点到VOD站的距离不超过k,问最少建新VOD站数. 思路 1. 令vod[i]为节点i到VOD站的最短距离,  注意,这是在以i为根的树上有VOD站的情况下,如果没有,vod[i]就设为非法. 依据树形DP的思路,如果在该…
Domination Time Limit: 8 Seconds      Memory Limit: 131072 KB      Special Judge Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. What's more, he bought a large decorative chessboar…
104. Little shop of flowers time limit per test: 0.25 sec. memory limit per test: 4096 KB PROBLEM You want to arrange the window of your flower shop in a most pleasant way. You have F bunches of flowers, each being of a different kind, and at least a…