提交时间:2024-01-07 14:34:18
运行 ID: 229981
#include <bits/stdc++.h> using namespace std; long long n; double a,b; double sum,t,m,total; bool d=false; int main() { scanf("%lld",&n); for(int i=1; i<=n; i++) { scanf("%lf%lf",&a,&b); if(b>a||a<=0||b<=0) d=true; sum+=b; total+=a; } scanf("%lf%lf",&t,&m); if(m>t) { printf("error\n"); return 0; } if(d==true) { printf("error\n"); return 0; } if(total>=t) total-=m; if(total<=0||sum<=0) { printf("error\n"); return 0; } printf("%.2lf\n",min(total,sum)); return 0; }