Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<fstream>
- using namespace std;
- int const MAXN=100000;
- int main()
- {
- ifstream cin("input.txt");
- ofstream cout("output.txt");
- int n, A[MAXN], B[MAXN], diff[MAXN];
- cin>>n;
- for(int i=0;i<n;i++) cin>>A[i];
- for(int i=0;i<n;i++) cin>>B[i];
- for(int i=0;i<n;i++) diff[i]=B[i]-A[i];
- int somma=0, lung=0, lungmax=0;
- for(int i=0;i<n;i++)
- {
- lung=0;
- somma=0;
- for(int j=i;j<n;j++)
- {
- somma+=diff[j];
- if(somma>=0) lung=j-i+1;
- }
- lungmax=max(lungmax, lung);
- }
- cout<<lungmax;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement