可以帮忙看看吗,B题
#include <iostream> #include <algorithm> using namespace std; const int N = 5010; int a[N],b[N]; int n,m,u,summ,sumu,res; int main() { cin>>n>>m>>u; for(int i=1;i<=n;i++) scanf("%d",&a[i]); for(int i=1;i<=n;i++) scanf("%d",&b[i]); for(int i=1,j=1;i<=n;i++) { summ += a[i]; sumu += b[i]; while(j <= i && (summ > m || sumu > u || sumu < 0)) { summ -= a[j]; sumu -= b[j]; j++; } res = max(res,i-j+1); } printf("%d",res); return 0; }