1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #include<iostream> #include<string> #include<fstream> using namespace std; int main() { freopen("out.txt","w+t",stdout); int n ,p ,cases = 1; string s; string comName ,nowCom; bool first = false; for( ; cin >> n >> p && n && p ; ++cases ){ if(first == false){ first = true; } else{ cout << "\n" << endl; } for( ; n+1 ; --n )getline(cin,s); double maxPrice = 0.0; int maxNum = 0; for( ; p ; --p ){ double comPrice = 0.0; int chkNum = 0; cin >> comName >> comPrice >> chkNum; if(maxNum<chkNum){ maxNum = chkNum; maxPrice = comPrice; nowCom = comName; } else if(maxNum==chkNum){ if(maxPrice>comPrice){ maxNum = chkNum; maxPrice = comPrice; nowCom = comName; } } for( ; chkNum+1 ; --chkNum )getline(cin,s); } cout << "RFP #" << cases << endl; cout << nowCom; } return 0; } |
Direct link: https://paste.plurk.com/show/292075