## 1020. 月饼 (25)

100 ms

65536 kB

8000 B

Standard

CHEN, Yue

3 20
18 15 10
75 72 45

94.50

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstring>
using namespace std;

struct inf
{
double save;
double sell_t;
}h[1000];

int N;
double D;

bool compare(const struct inf &a, const struct inf &b)
{
return a.sell_t * b.save > b.sell_t * a.save;
}

void solve()
{
sort(h, h + N, compare);

double sum = 0;
for(int i = 0; i < N; i ++){
int d = min(h[i].save, D);
if(d){
sum += h[i].sell_t * d / h[i].save;
D -= d;
}
}

printf("%.2lf\n", sum);
}

int main()
{
cin >> N >> D;
for(int i = 0; i < N; i ++){
cin >> h[i].save;
}
for(int i = 0; i < N; i ++){
cin >> h[i].sell_t;
}
solve();
return 0;
}

#### PAT (Basic Level) Practise （中文） 1020 月饼 (25)

2017-03-24 21:00:59

#### PAT乙级—1020. 月饼 (25)-native

2016-05-03 17:23:38

#### 编程题目： PAT 1020. 月饼 (25)

2014-07-04 15:22:53

#### PAT Basic 1020. 月饼 (25)（C语言实现）

2017-05-18 23:45:17

#### PAT1020月饼

2016-02-18 12:02:53

#### 1020. 月饼 (25) Python篇

2017-04-13 20:34:42

#### 【C++】浙大PAT (Basic Level)1020. 月饼 (25)

2014-01-31 16:25:15

#### 1020. 月饼 (25)--浙大PAT乙级真题java实现

2018-01-17 14:20:42

#### PAT(B) - 1020. 月饼 (25)

2016-09-03 23:26:27

#### PAT 1020. 月饼

2015-03-06 16:22:56

1020. 月饼 (25)