题目链接
https://pintia.cn/problem-sets/994805046380707840/problems/994805071789801472
视频讲解https://www.bilibili.com/video/BV1NL4y1E7kr
思路我们用一个结构体存储每一个月饼的 库存量 和 总售价,然后再定义一个变量c存储单位体积的售价,然后我们将每一种月饼按照单位体积售价从大到小排序,从前往后能选多少是多少
代码#include
using namespace std;
#define ll long long
#define mod 1000000007
#define endl "\n"
#define PII pair
#define INF 0x3f3f3f3f
const int N = 1e3+10;
int n,d;
struct Node{
double a,b,c;
}a[N];
bool cmp(Node a,Node b) {
return a.c > b.c;
}
int main()
{
scanf("%d%d",&n,&d);
for(int i = 1;i
关注
打赏