Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
173595 C班-赵奕博 国王游戏 C++ 无测评数据 0 0 MS 0 KB 814 2024-08-20 21:56:03

Tests(0/0):


#include <iostream> #include <algorithm> using namespace std; struct Minister { int left; int right; }; bool compareMinisters(Minister a, Minister b) { return a.left * b.right < b.left * a.right; } int main() { int n; cin >> n; int kingLeft, kingRight; cin >> kingLeft >> kingRight; Minister ministers[n]; for (int i = 0; i < n; i++) { cin >> ministers[i].left >> ministers[i].right; } sort(ministers, ministers + n, compareMinisters); int maxReward = 0; int currentProduct = kingLeft; for (int i = 0; i < n; i++) { int reward = currentProduct / ministers[i].right; maxReward = max(maxReward, reward); currentProduct *= ministers[i].left; } cout << maxReward << endl; return 0; }