提交时间:2024-01-29 19:41:58
运行 ID: 234748
#include <iostream> #include <iomanip> using namespace std; int n; double a[100005], b[100005]; int main() { cin >> n; double aans(0), bans(0); for (int i = 1; i <= n; i++) { cin >> a[i] >> b[i]; if (b[i] > a[i] || a[i] < 0 || b[i] < 0) { cout << "error"; return 0; } aans += b[i]; bans += a[i]; } double x, y; cin >> x >> y; if (y > x || y < 0 || x < 0) { cout << "error"; return 0; } if (bans >= x) bans -= y; cout << fixed << setprecision(2) << min(aans, bans); }