思路
一个很经典的推公式题目
有点潦草, 将就看吧
意思就是写出 价值s 的表达式 然后尝试交换, 把相同的部分删掉
可以得到最后的表达式是 :
bool cmp (const pii& pi , const pii & pi1)
{
return pi.first * pi.second < pi1.first * pi1.second;
}
最后统计一下价格就行
##ac 代码
#include<bits/stdc++.h>
using namespace std;
const int N =1e5+10;
const int inf = INT_MAX ;
typedef pair <int, int > pii;
typedef priority_queue<int ,vector<int> ,greater<int>> small_heap;
#define int long long
bool cmp (const pii& pi , const pii & pi1)
{
return pi.first * pi.second < pi1.first * pi1.second;
}
int32_t main()
{
int n ;
cin >> n;
vector <pii> a (n+1);
for(int i = 0 ; i<=n;i++)
{
int l ,r ;
cin >> l>>r;
a[i] = {l,r};
}
sort(a.begin() + 1, a.end() , cmp);
// for(auto& [ l ,r] : a)
// {
// cout << l <<" "<< r <<endl;
// }
// cout << endl<<endl<<"debug"<<endl;
int ans = 0 ;
int s = 0 ;
int total_l = 1;
for(int i = 1 ;i<=n;i++)
{
total_l *= a[i-1].first;
s = total_l / a[i].second;
ans = max(ans , s );
}
cout << ans;
return 0;
}