Codeforces 1469B. Red and Blue Solution

  Solution in C++:

///**********ALLAH IS ALMIGHTY************///

///AH Tonmoy

///Department of CSE,23rd batch

///Islamic University,Bangladesh  

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int t,i,j,m,n,k;
  6. cin>>t;
  7. while(t--)
  8. {
  9. cin>>n;
  10. int r,mx=0,s=0;
  11. for(i=0; i<n; i++)
  12. {
  13. cin>>r;
  14. s=s+r;
  15. mx=max(mx,s);
  16. }
  17. cin>>m;
  18. int b,mx2=0;
  19. s=0;
  20. for(i=0; i<m; i++)
  21. {
  22. cin>>b;
  23. s=s+b;
  24. mx2=max(mx2,s);
  25. }
  26. cout<<mx+mx2<<endl;
  27. }
  28. }

No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.