Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
168625 | 李熙宸 | 国王游戏 | C++ | 解答错误 | 60 | 1 MS | 268 KB | 830 | 2024-08-20 11:53:50 |
#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; }