poj 1456.Supermarket
来源:互联网 发布:淘宝凤求凰cdk抽奖 编辑:程序博客网 时间:2024/05/22 04:40
Supermarket
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;#define N 10010int pre[N];struct node{int profit, deadline;}p[N];bool operator < (const node& a, const node& b){return a.profit > b.profit;}int find(int x){int root, temp;root = x;while(root != pre[root])root = pre[root];while(x != root){temp = pre[x];pre[temp] = root;x = temp;}return root;}int main(){int num;int root;int maxprofit;while(~scanf("%d", &num)){maxprofit = 0;for(int i = 1; i < N; ++i)pre[i] = i;for(int i = 0; i < num; ++i)scanf("%d%d", &p[i].profit, &p[i].deadline);sort(p, p + num);for(int i = 0; i < num; ++i){root = find(p[i].deadline);if(root > 0){pre[root] = root - 1;maxprofit += p[i].profit;}}printf("%d\n", maxprofit);}return 0;}
- poj 1456.Supermarket
- POJ Supermarket
- POJ Supermarket
- Supermarket POJ
- POJ 1297 Supermarket
- poj 1456 supermarket
- POJ-1456 Supermarket【贪心】
- poj 1456 Supermarket
- Supermarket poj 1456
- POJ 1456 Supermarket
- POJ 1456 Supermarket
- POJ-1456-Supermarket
- poj 1456 Supermarket
- poj 1456 Supermarket
- POJ - 1456 Supermarket
- POJ 1456 Supermarket
- POJ 1456 Supermarket
- POJ 1456 Supermarket
- 知易游戏开发教程cocos2d-x移植版004
- 创建SQlHelper类
- 感悟这句话
- linux中probe函数中传递的参数来源(上)
- Extjs4 GridPanel的主要配置参数-详解
- poj 1456.Supermarket
- Apache—DBUtils框架
- 数据结构学习四(KMP算法实现)
- java经典算法_031计算字符串中子串出现的次数
- WEB开发基本理论
- javascript 小应用
- Win8 小动画的实现
- android开发--Canvas清屏只需三句话
- 单位转换