超市购物
题目链接:超市购物
题目描述
解题思路
这很明显是一道贪心。
我们先以价格为关键字排序,再一一枚举。如果当前货物被选中,那么其他的货物就推到第二天,这个操作我们可以用并查集实现。
code
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
int fa[100010];
struct abc{
int p,d;
题目链接:超市购物
这很明显是一道贪心。
我们先以价格为关键字排序,再一一枚举。如果当前货物被选中,那么其他的货物就推到第二天,这个操作我们可以用并查集实现。
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
int fa[100010];
struct abc{
int p,d;