UVa 10141 - Request for Proposal

来源:互联网 发布:苹果删不掉windows系统 编辑:程序博客网 时间:2024/06/07 05:48

题目:政府要做n个项目,对p个公司招标,政府想知道哪家公司能做的项目最多并且花费更少。

分析:简单题。因为每个厂家提供的方案都在招标的列表中,直接计数比较即可。

说明:注意数据格式,有几天没刷题了,要赶快不少( ⊙ o ⊙ )啊!。

#include <algorithm>#include <iostream>#include <cstdlib>#include <cstring>#include <string>#include <cstdio>#include <cmath>using namespace std;string P[1001], temp, name, ans;int main(){int n, p, T = 0;while (~scanf("%d%d", &n, &p) && n) {getchar();for (int i = 0 ; i < n ; ++ i)getline(cin, P[i]);int maxm = 0, count, number;doublecost = 0.0,price;for (int i = 0 ; i < p ; ++ i) {getline(cin, name);scanf("%lf%d", &price, &number);getchar();count = 0;for (int j = 0 ; j < number ; ++ j) {getline(cin, temp);count ++;}if (maxm == count && cost > price) {cost = price;ans  = name; }if (maxm < count) {maxm = count;cost = price;ans  = name;}}if (T ++) printf("\n");cout << "RFP #" << T << endl;cout << ans << endl;}    return 0;}


0 0
原创粉丝点击