题目意思能搞成这样我也是服了这个女人了

#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm> using namespace std; int main() {
int N = ;
double D = ;
scanf("%d%lf", &N, &D);
vector<pair<double, double> > base(N);
vector<double> amount(N);
vector<double> price(N);
double tmp;
for (int i=; i<N; i++) {
scanf("%lf", &amount[i]);
}
for (int i=; i<N; i++) {
scanf("%lf", &price[i]);
base[i].first = amount[i] / price[i];
base[i].second= i;
} sort(base.begin(), base.end()); double cur = ;
double mon = ;
int i = ; while(cur < D && i < N) {
int idx = base[i].second;
double use = amount[idx];
if ((use + cur) >= D) use = D - cur;
mon += use / amount[idx] * price[idx];
cur += use;
i++;
}
printf("%.2lf", mon);
return ;
}

PAT 1070 Mooncake的更多相关文章

  1. PAT 1070 Mooncake[一般]

    1070 Mooncake (25)(25 分) Mooncake is a Chinese bakery product traditionally eaten during the Mid-Aut ...

  2. PAT 1070. Mooncake (25)

    Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival.  Many types ...

  3. PAT 甲级 1070 Mooncake (25 分)(结构体排序,贪心,简单)

    1070 Mooncake (25 分)   Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autum ...

  4. 1070 Mooncake (25 分)

    1070 Mooncake (25 分) Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn ...

  5. 【PAT甲级】1070 Mooncake (25 分)(贪心水中水)

    题意: 输入两个正整数N和M(存疑M是否为整数,N<=1000,M<=500)表示月饼的种数和市场对于月饼的最大需求,接着输入N个正整数表示某种月饼的库存,再输入N个正数表示某种月饼库存全 ...

  6. PAT Advanced 1070 Mooncake (25) [贪⼼算法]

    题目 Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many typ ...

  7. PAT (Advanced Level) 1070. Mooncake (25)

    简单贪心.先买性价比高的. #include<cstdio> #include<cstring> #include<cmath> #include<vecto ...

  8. PAT甲题题解-1070. Mooncake (25)-排序,大水题

    #include <iostream> #include <cstdio> #include <algorithm> #include <string.h&g ...

  9. 1070. Mooncake (25)

    题目如下: Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many ...

随机推荐

  1. 洛谷P4494 [HAOI2018]反色游戏(tarjan)

    题面 传送门 题解 我们先来考虑一个联通块,这些关系显然可以写成一个异或方程组的形式,形如\(\oplus_{e\in edge_u}x_e=col_u\) 如果这个联通块的黑色点个数为奇数,那么显然 ...

  2. python3入门之字符串

    获得更多资料欢迎进入我的网站或者 csdn或者博客园 经过前面的介绍相信大家也对python有了一个初步的了解:本节主要介绍字符串,不管学习什么编语言字符串一定在其中扮演着重要的地位.本节主要讲解,字 ...

  3. 条目十二《切勿对slt容器的线性安全性又不切实际的依赖》

    条目十二<切勿对slt容器的线性安全性又不切实际的依赖> 这一条目,我想用简短而有力的语句来总结. stl库是为了照顾大多数情况,而不是某一领域,如果在库层次实现线性安全,很大可能是对性能 ...

  4. springcloud整合bus

    bus的使用主要是配合springcloud config部分来一起使用,并没有单独使用 首先建立服务端: <dependency> <groupId>org.springfr ...

  5. Java实现二维码生成的方法

    1.支持QRcode.ZXing 二维码生成.解析: package com.thinkgem.jeesite.test; import com.google.zxing.BarcodeFormat; ...

  6. Spring Eureka的使用入门

    Eureka调度服务: Gradle依赖包: 基础框架依赖配置核心代码: buildscript { repositories { mavenCentral() } dependencies {cla ...

  7. git 设置代理.

    git 设置代理:(因为网络有时太慢,需要用到 ss 代理..) git config --global http.proxy http://127.0.0.1:1080 取消 代理 git conf ...

  8. 使用 v-model 实现 双向绑定.(子组件和父组件.)

    vue 自定义组件 v-model双向绑定. 父子组件同步通信   父子组件通信,都是单项的,很多时候需要双向通信.方法如下: 1.父组件使用:msg.sync="aa"  子组件 ...

  9. IDEA 在 专注模式下 显示 行号 和 缩进线...

    16down voteaccepted +50 Open the settings and navigate to Editor > General > Appearance and ti ...

  10. pscp 命令---windows和linux之间互相拷贝文件的工具

    pscp -r d:\cc root@10.0.0.8:/root/test copy d:\cc content recursively into the /root/test, contains ...