首页 > TAG信息列表 > 1456

Supermarket POJ - 1456【并查集】

Supermarket POJ - 1456 题目 思路:贪心 + 并查集优化,先把数对按照价值从大到小排序,然后依次枚举,枚举到不能用的就跳过,有点像kruskal? 具体代码如下 #include<iostream> #include<cstring> #include<algorithm> #include<cstdio> using namespace std; const int N = 10010;

LeetCode 1456. 定长子串中元音的最大数目

地址 https://leetcode-cn.com/contest/weekly-contest-190/problems/maximum-number-of-vowels-in-a-substring-of-given-length/ 题目描述 给你字符串 s 和整数 k 。 请返回字符串 s 中长度为 k 的单个子字符串中可能包含的最大元音字母数。 英文中的 元音字母 为(a, e, i, o

【POJ-1456】 Supermarket

#include <iostream> #include <algorithm> #include <vector> using namespace std; const int SIZE = 1 << 20; vector<pair <int,int> > vec; int fa[SIZE]; bool cmp(pair<int,int> a,pair<int,int> b) { return a.fi

Supermarket( POJ - 1456,小根堆 + 贪心)

一.题目链接: POJ-1456 二.题目大意: 有 n 个商品. 每个商品有两个属性,保质期天数 和 利润. 一天只能卖一个商品且过期的商品无法销售,求最大利润. 三.分析: 首先对保质期由小到大排序. 准备一个小根堆存放商品的利润. 小根堆的大小 size 表示 1~size 天的所售卖的商品. 之后遍历商

poj 1456 Supermarket 贪心+优先队列

题目链接:http://poj.org/problem?id=1456 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 time units starting from the moment the sale