国产探花免费观看_亚洲丰满少妇自慰呻吟_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);}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 彰武县| 绵竹市| 峨边| 天门市| 溧水县| 九寨沟县| 池州市| 贡嘎县| 淳安县| 朝阳县| 肃南| 景泰县| 三河市| 合作市| 千阳县| 孟津县| 漯河市| 金坛市| 长葛市| 达孜县| 彰化市| 绥芬河市| 都兰县| 宜川县| 海城市| 彝良县| 遵义市| 商都县| 从江县| 逊克县| 永寿县| 抚远县| 五莲县| 海门市| 横峰县| 古蔺县| 保定市| 潼关县| 铜山县| 中宁县| 乌兰察布市|