POJ 2433 Landscaping (贪心)】的更多相关文章

题意:给定一个序列表示一群山,要你保留最多 K 个山峰,最少要削去多少体积和土.一个山峰是指一段连续的相等的区间,并且左边和右边只能比这个区间低,或者是边界. 析:贪心,每次都寻找体积最小的山峰,然后把它削去,每次削的是最小的,所以是满足贪心的,最后剩下的小于 K 个就可以了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string…
#include <string.h> #include <iostream> #include <queue> #include <stdio.h> using namespace std; struct product{ int deadline; int val; friend bool operator<(product n1,product n2) { return n1.val<n2.val; } }q; ]; int main()…
http://poj.org/problem?id=3614 有c头奶牛在沙滩上晒太阳,每头奶牛能忍受的阳光强度有一个最大值(max_spf) 和最小值(min_spf),奶牛有L种防晒霜,每种可以固定阳光强度在某一个值,每种的数量是cover[i] ,每头奶牛只能用一瓶防晒霜,问最多有多少头奶牛能在沙滩上晒太阳. 理解题意之后还是挺好做的. 首先确定的贪心策略是,在满足min_spf的条件下,尽量用spf小的用在max_spf大的奶牛身上,用一个最小堆维护max_spf的最小值即可. 先对奶牛…
题目链接: http://poj.org/problem?id=3614 Sunscreen Time Limit: 1000MSMemory Limit: 65536K 问题描述 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…
题目链接:http://poj.org/problem?id=1456 Time Limit: 2000MS Memory Limit: 65536K Description A supermarket has a set Prod of products on sale. It earns a profit px for each product x∈Prod sold by a deadline dx that is measured as an integral number of tim…
Bridge over a rough river Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4143   Accepted: 1703 Description A group of N travelers (1 ≤ N ≤ 50) has approached an old and shabby bridge and wishes to cross the river as soon as possible. Ho…
Tian Ji -- The Horse Racing Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 12490   Accepted: 3858 Description Here is a famous story in Chinese history. That was about 2300 years ago. General Tian Ji was a high official in the country Q…
地址 http://poj.org/problem?id=2431 题解 朴素想法就是dfs 经过该点的时候决定是否加油 中间加了一点剪枝 如果加油次数已经比已知最少的加油次数要大或者等于了 那么就剪枝 然而 还是TLE了 TLE代码 #include <iostream> #include <vector> #include <algorithm> #include <queue> using namespace std; vector<pair&l…
简单的说说思路,如果一开始能够去到目的地那么当然不需要加油,否则肯定选择能够够着的油量最大的加油站加油,,不断重复这个贪心的策略即可. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <queue> using namespace std; const int maxn=1e4+9; int dist,p,n; struc…
//poj 3154 //sep9 #include <iostream> #include <cmath> using namespace std; double a[2048]; double b[2048]; int main() { int n,m; while(scanf("%d%d",&n,&m)==2){ for(int i=0;i<n;++i) a[i]=i*(10000.0/n); for(int i=0;i<(n+…