标签:blog io ar os sp for 数据 2014 log
题目:政府要做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; double cost = 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; }
UVa 10141 - Request for Proposal
标签:blog io ar os sp for 数据 2014 log
原文地址:http://blog.csdn.net/mobius_strip/article/details/41889551