国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

1070. Mooncake (25)

2019-11-08 02:55:26
字體:
來源:轉載
供稿:網友

計算出單價,對此進行排序,然后從大到小的篩選就好了

#include<iostream>#include<vector>#include<algorithm>#PRagma warning(disable:4996)using namespace std;struct node { double n, m, p;//數量,總金額,單價 bool Operator<(const node that)const { return this->p < that.p; }};int main(){ int N, M; vector<node> all; cin >> N >> M; all.resize(N); for (int t = 0;t < N;t++) scanf("%lf", &all[t].n); for (int t = 0;t < N;t++) { scanf("%lf", &all[t].m); all[t].p = all[t].m / all[t].n; } sort(all.rbegin(), all.rend()); double resault = 0; for (auto x : all) { if (x.n > M) { resault += M*x.p;break; } if (x.n <= M) { resault += x.m; M -= x.n; } } printf("%.2lf/n", resault);}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 齐河县| 库尔勒市| 湖州市| 天柱县| 牙克石市| 鹿邑县| 金沙县| 玛曲县| 三原县| 会理县| 额济纳旗| 多伦县| 西林县| 韶山市| 宁乡县| 禄丰县| 通化县| 荃湾区| 南皮县| 重庆市| 建湖县| 英德市| 高碑店市| 循化| 安塞县| 江源县| 全州县| 长宁县| 瓮安县| 台州市| 北京市| 蚌埠市| 盐城市| 双江| 博爱县| 沙河市| 苗栗市| 松江区| 巫山县| 宜丰县| 独山县|