POJ1456 Supermarket 贪心】的更多相关文章

题目链接:http://poj.org/problem?id=1456 Supermarket Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 13736   Accepted: 6206 Description A supermarket has a set Prod of products on sale. It earns a profit px for each product x∈Prod sold by a d…
贪心策略:一定先卖价值最大的,然后考虑卖当前的物品,卖的日期越靠后,越优,可以为以后的物品提供机会 #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; ; struct Node{ int v,d; bool operator<(const Node &rhs)const{ return v>rhs.v; } }p[N]; bool vis[…
题目链接:http://poj.org/problem?id=1456 题意:有n个物品(0 <= n <= 10000) ,每个物品有一个价格pi和一个保质期di (1 <= pi <= 10000, 1 <= di <= 10000),物品必须在保质期之前卖出.且每天只能卖出一个物品,问如何安排才能使卖出的总价格最大. 这道题贪心的思想很明显,先将物品的价格按照从大到小排序,再按照该顺序卖物品,如果存在不超过保质期的最大可用日期,则该物品能够卖出,并将这一天标记.关…
题目链接:https://cn.vjudge.net/problem/POJ-1456 此题与HDU-1789完全是一道题 题意 有N件商品,分别给出商品的价值和销售的最后期限,只要在最后日期之前销售处,就能得到相应的利润,并且销售该商品需要1天时间. 问销售的最大利润. 思路 详见HDU-1789 代码 注意题中n可为0 #include <cstdio> #include <algorithm> using namespace std; struct Product{ int…
Supermarket Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10725 Accepted: 4688 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 integr…
题目链接:http://poj.org/problem?id=1456 题目大意: 有N件商品,分别给出商品的价值和销售的最后期限,只要在最后日期之前销售处,就能得到相应的利润,并且销售该商品需要1天时间. 问销售的最大利润.   我开始的代码:(贪心策略有问题,因为我当时以为过期时间短的商品要优先卖掉,实际上不是这样的) #include <cstdio> #include <cstring> #include <algorithm> using namespace…
传送门 1.贪心 + 优先队列 按照时间排序从前往后 很简单不多说 ——代码 #include <queue> #include <cstdio> #include <iostream> #include <algorithm> #define N 10001 int n, t, ans; std::priority_queue <int, std::vector <int>, std::greater <int> > q…
题目链接: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…
Supermarket Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 14656   Accepted: 6656 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 in…
题目传送门 Supermarket Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 15192   Accepted: 6855 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…