洛谷P2877 [USACO07NOV]防晒霜Sunscreen】的更多相关文章

题目 此题有多种贪心方法. 首先简化题意: 有几个在数轴上的区间,和几个在数轴上确定的位置的点,问用这些数目的点,最多能满足多少个区间里有点. 注意:此题跟区间选点问题不一样,每个点只能满足一个区间,而区间选点则可以满足多个区间. 进行贪心分析: 我们首先考虑区间,首先把最难满足的放在前面,可以把l从大到小排序,也可以把r从小到大排序. 再次注意:此时满足的困难程度并不是取决于所有点,而是根据一个点来确定区间的难易. 因为对于一个点,如果l小的区间不满足,l比它大的区间肯定不会满足,所以l大的比…
P2887 [USACO07NOV]防晒霜Sunscreen 题目描述 To avoid unsightly burns while tanning, each of the C (1 ≤ C ≤ 2500) cows must cover her hide with sunscreen when they're at the beach. Cow i has a minimum and maximum SPF rating (1 ≤ minSPFi ≤ 1,000; minSPFi ≤ max…
原题 传送门 有C个奶牛去晒太阳 (1 <=C <= 2500),每个奶牛各自能够忍受的阳光强度有一个最小值和一个最大值(minSPFi and maxSPFi),太大就晒伤了,太小奶牛没感觉. 而刚开始的阳光的强度非常大,奶牛都承受不住,然后奶牛就得涂抹防晒霜,防晒霜的作用是让阳光照在身上的阳光强度固定为某个值. 那么为了不让奶牛烫伤,又不会没有效果. 给出了L种防晒霜.每种的数量和固定的阳光强度(coveri and SPFi)也给出来了 每个奶牛只能抹一瓶防晒霜,最后问能够享受晒太阳的奶…
Sunscreen Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9333   Accepted: 3264 Description To avoid unsightly burns while tanning, each of the C (1 ≤ C ≤ 2500) cows must cover her hide with sunscreen when they're at the beach. Cow i has…
题意很简单,给一张图,把基本的求起点到终点最短路改成求经过k条边的最短路. 求最短路常用的算法是dijkstra,SPFA,还有floyd. 考虑floyd的过程: c[i][j]=min(c[i][j],a[i][k]+b[k][j]); 自然而然联想到矩阵乘法,每次加入一个点就相当于多加一条边,那么加k次就是k条边的最短路. 但是k可能很大(见数据范围),那么显然直接循环矩乘k次是行不通的,于是就想到了矩阵快速幂. 和普通快速幂一样的方式,只不过是把乘法替换成矩乘. 代码如下: #inclu…
题目戳 题目描述 Farmer John wants the cows to prepare for the county jumping competition, so Bessie and the gang are practicing jumping over hurdles. They are getting tired, though, so they want to be able to use as little energy as possible to jump over th…
题目描述 Farmer John wants the cows to prepare for the county jumping competition, so Bessie and the gang are practicing jumping over hurdles. They are getting tired, though, so they want to be able to use as little energy as possible to jump over the hu…
题面 解题思路 ## floyd+矩阵快速幂,跟GhostCai爷打赌用不用离散化,最后完败..GhostCai真是tql ! 有个巧妙的方法就是将节点重新编号,因为与节点无关. 代码 #include<bits/stdc++.h> using namespace std; const int MAXN = 1005; int n,t,s,e; int edge[MAXN][MAXN]; int num[MAXN],tot; struct Mat{ int a[105][105]; Mat o…
本题就是求两点间只经过n条边的最短路径,定义广义的矩阵乘法,就是把普通的矩阵乘法从求和改成了取最小值,把内部相乘改成了相加. 代码包含三个内容:广义矩阵乘法,矩阵快速幂,离散化: 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int INF=0x3f3f3f3f; 4 const int N=120; 5 int Hash[1000005],cnt=0;//用于离散化 6 struct matrix{ 7 int m[N][N…
bzoj炸了,靠离线版题目做了两道(过过样例什么的还是轻松的)但是交不了,正巧洛谷有个"大牛分站",就转回洛谷做题了 水题先行,一道傻逼匈牙利 其实本来的思路是搜索然后发现写出来类似于匈牙利(⊙o⊙) (匈牙利的复杂度惊人,1e6秒过) #include <cstdio> ]; ],fir[],to[],nex[]; int N,n,p,q; void add(int p,int q) { nex[++N]=fir[p];to[N]=q;fir[p]=N; } bool f…