提交时间:2024-08-20 23:01:00
运行 ID: 173654
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a, b; cin >> a >> b; vector<pair<int, int>> minis(n); for (int i = 0; i < n; ++i) { cin >> minis[i].first >> minis[i].second; } sort(minis.begin(), minis.end(), [](pair<int, int>& x, pair<int, int>& y) { return x.first * y.second > y.first * x.second; }); long long nowp = a; int maxc = 0; for (int i = 0; i < n; ++i) { int coins = nowp / minis[i].second; maxc = max(maxc, coins); nowp *= minis[i].first; } cout << maxc << endl; return 0; }