Codeforces 1469B. Red and Blue Solution
Solution in C++:
///**********ALLAH IS ALMIGHTY************///
///AH Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int t,i,j,m,n,k;
- cin>>t;
- while(t--)
- {
- cin>>n;
- int r,mx=0,s=0;
- for(i=0; i<n; i++)
- {
- cin>>r;
- s=s+r;
- mx=max(mx,s);
- }
- cin>>m;
- int b,mx2=0;
- s=0;
- for(i=0; i<m; i++)
- {
- cin>>b;
- s=s+b;
- mx2=max(mx2,s);
- }
- cout<<mx+mx2<<endl;
- }
- }
No comments