County Fair Events】的更多相关文章

先按时间排序( 开始结束都可以 ) , 然后 dp( i ) = max( dp( i ) , dp( j ) + 1 ) ( j < i && 节日 j 结束时间在节日 i 开始时间之前 ) answer = max( dp( i ) ) ( 1 <= i <= n ) -------------------------------------------------------------------------------- #include<cstdio&g…
1664: [Usaco2006 Open]County Fair Events 参加节日庆祝 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 255  Solved: 185[Submit][Status][Discuss] Description Farmer John has returned to the County Fair so he can attend the special events (concerts, rodeos, coo…
Description Farmer John has returned to the County Fair so he can attend the special events (concerts, rodeos, cooking shows, etc.). He wants to attend as many of the N (1 <= N <= 10,000) special events as he possibly can. He's rented a bicycle so h…
http://www.lydsy.com/JudgeOnline/problem.php?id=1664 和之前的那题一样啊.. 只不过权值变为了1.. 同样用线段树维护区间,然后在区间范围内dp. upd:(其实权值为1的可以直接贪心....右端点来就行了... #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream>…
Description Farmer John has returned to the County Fair so he can attend the special events (concerts, rodeos, cooking shows, etc.). He wants to attend as many of the N (1 <= N <= 10,000) special events as he possibly can. He's rented a bicycle so h…
将区间按左端点排序. f(i)=max{f(j)+1}(p[j].x+p[j].y<=p[i].x && j<i) #include<cstdio> #include<algorithm> using namespace std; int n,f[10001]; struct Point{int x,y;}p[10001]; bool operator < (const Point &a,const Point &b){return…
把长度转成右端点,按右端点排升序,f[i]=max(f[j]&&r[j]<l[i]),因为r是有序的,所以可以直接二分出能转移的区间(1,w),然后用树状数组维护区间f的max,每次转移的时候直接从树状数组上查询前缀max即可,然后把更新出来的f[i]update进树状数组 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int N…
先按照结束时间进行排序,取第一个节日的结束时间作为当前时间,然后从第二个节日开始搜索,如果下一个节日的开始时间大于当前的时间,那么就参加这个节日,并更新当前时间 #include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e4+5; struct node { int be, ed; // 开始时间和结束时间 }nds[maxn]; bool cmp(node x, node y)…
大神们都在刷usaco,我也来水一水 1606: [Usaco2008 Dec]Hay For Sale 购买干草   裸背包 1607: [Usaco2008 Dec]Patting Heads 轻拍牛头 神转化,筛法 1609: [Usaco2008 Feb]Eating Together麻烦的聚餐  LIS 1610: [Usaco2008 Feb]Line连线游戏 排序 1611: [Usaco2008 Feb]Meteor Shower流星雨  BFS 1612: [Usaco2008…
bzoj上的usaco题目还是很好的(我被虐的很惨. 有必要总结整理一下. 1592: [Usaco2008 Feb]Making the Grade 路面修整 一开始没有想到离散化.然后离散化之后就很好做了.F[I,j]表示第i个点,高度>=j或<=j,f[I,j]=min(f[i-1,j]+abs(b[j]-a[i]),f[I,j-1]) 1593: [Usaco2008 Feb]Hotel 旅馆 线段树 ★1594: [Usaco2008 Jan]猜数游戏 二分答案然后写线段树维护 15…