'commit'
This commit is contained in:
33
TangDou/AcWing/114.cpp
Normal file
33
TangDou/AcWing/114.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
const int N = 10010;
|
||||
typedef long long LL;
|
||||
struct Person {
|
||||
int left, right;
|
||||
} person[N];
|
||||
int n;
|
||||
|
||||
bool cmp(const Person &a, const Person &b) {
|
||||
return a.left * a.right < b.left * b.right;
|
||||
}
|
||||
|
||||
int main() {
|
||||
cin >> n;
|
||||
//输入
|
||||
for (int i = 0; i <= n; i++)
|
||||
cin >> person[i].left >> person[i].right;
|
||||
//排序,注意国王不参加排序
|
||||
sort(person + 1, person + 1 + n, cmp);
|
||||
|
||||
LL lcj = 1;//连乘积
|
||||
LL res = 0;
|
||||
for (int i = 0; i <= n; i++) {
|
||||
//猴子选大王
|
||||
res = max(res, lcj / person[i].right);
|
||||
//更新连乘各
|
||||
lcj *= person[i].left;
|
||||
}
|
||||
printf("%d", res);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user