题解
2025-11-30 16:18:42
发布于:湖南
12阅读
0回复
0点赞
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
while (n--) {
long long a, b;
cin >> a >> b;
if (a >= b) {
cout << a << '\n';
continue;
}
long long x_min = max(b - a, 0LL);
long long x_max = min(a, b / 2);
if (x_min > x_max) {
cout << 0 << '\n';
} else {
cout << a - x_min << '\n';
}
}
return 0;
}
这里空空如也




有帮助,赞一个