分析
- 视频讲解:
- 我不是匠人
- 思路
- 求最值
代码
/*
1. 记录最值
*/
#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
cin >> n;
string id;
int price, count;
string bestId, bestId2;
int bestCount = -1;
int bestTotal = -1;
for(int i = 0; i < n; i++) {
cin >> id >> price >> count;
if(count > bestCount) {
bestCount = count;
bestId = id;
}
if(price*count > bestTotal){
bestTotal = price*count;
bestId2 = id;
}
}
cout<<bestId<<" "<<bestCount<<endl;
cout<<bestId2<<" "<<bestTotal<<endl;
return 0;
}