算法
(暴力枚举) O(n)
暴力枚举符合条件的最小值即可。
C++ 代码
#include <iostream>
template <typename T>
bool chkmax(T &x, T y) {
return x < y ? x = y, true : false;
}
template <typename T>
bool chkmin(T &x, T y) {
return x > y ? x = y, true : false;
}
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
int ans = 1e9;
while (n--) {
int x, y;
cin >> x >> y;
int ed = m / x;
if (m % x) ed++;
chkmin(ans, ed * y);
}
cout << ans << '\n';
}
return 0;
}