please check my submission. I am confused. why my code is showing wrong ans.
#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
int gas[n], cost[n];
for(int i=0; i<n; i++){
cin>>gas[i];
}
for(int i=0; i<n; i++){
cin>>cost[i];
}
int net = 0, curr = 0,start = 0;
for(int i=0; i<n; i++){
net += (gas[i] - cost[i]);
curr += (gas[i] - cost[i]);
if(curr < 0){
start = i+1;
curr = 0;
}
}
if(net < 0) cout<<"-1";
else cout<<start;
return 0;
}