FAST FOOD(struggled for one hour)

Can anyone help ? my logic is corrcet.

#include<bits/stdc++.h>
using namespace std;
int main(){
		int t;
		cin>>t;
		while(t--){
			int n;
			cin>>n;
			vector<int>a(n+1),b(n+1),pa(n+1),pb(n+1);
			for(int i=1;i<n+1;i++){
				cin>>a[i];
			}
			for(int i=1;i<n+1;i++){
				cin>>b[i];
			}
			for(int i=1;i<n+1;i++){
				pa[i]+=pa[i-1]+a[i];
			}
			for(int i=1;i<n+1;i++){
				pb[i]+=pb[i-1]+b[i];
			}
			int s=0;
			for(int i=1;i<=n;i++){
				if(b[i]>a[i]&&(pb[n]-pb[i-1]>pa[n]-pa[i-1])){
					s+=(pb[n]-pb[i-1]);
					break;
				}
				else{
					s+=a[i];
				}
			}
			cout<<s<<"\n";
			
			
			
			
		}
		    
		    
}
	



here is the problem link CodeChef: Practical coding for everyone

got one testcase
3 3 3 6 5 8
2 2 2 7 1 13

correct answer - 33
my code answer - 30

@iphone_11 - doubt support by other codecheffers is now active between problems of difficulty rating 1400 - 1600. this problems is a 1530 diff problem - you should access the doubt solver here - CodeChef: Practical coding for everyone