Help regarding deputy chef

Can somebody please identify the problem with the code? Thanks in advance.

#include<bits/stdc++.h>
using namespace std;

int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<int> a(n);
        vector<int> d(n);
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        for(int i=0;i<n;i++){
            cin>>d[i];
        }
        int ans=-1;
        vector<int> net_attack(n);
        for(int i=0;i<n;i++){
            net_attack[i]=a[(i+1)%n]+a[(n+i-1)%n];
        }
        // for(int i=0;i<n;i++){
        //     cout<<net_attack[i]<<" ";
        // }
        // cout<<endl;
        for(int i=0;i<n;i++){
            if(d[i]>net_attack[i]){
                ans=d[i];
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}