提交时间:2024-08-20 11:53:50

运行 ID: 168625

#include <iostream> #include <algorithm> using namespace std; struct Minister { int left, right; bool operator<(const Minister& other) const { return right * left < other.right * other.left; } }; int main() { int n; cin >> n; int king_left, king_right; cin >> king_left >> king_right; Minister ministers[1001]; for (int i = 0; i < n; i++) cin >> ministers[i].left >> ministers[i].right; sort(ministers, ministers + n); long long max_reward = 0, product = king_left; for (int i = 0; i < n; i++) { long long reward = product / ministers[i].right; max_reward = max(max_reward, reward); product *= ministers[i].left; } cout << max_reward << endl; return 0; }