SHARE
TWEET

Untitled

kaa7 May 22nd, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. #define MAXN 101
  3. using namespace std;
  4. int n, A[2][MAXN], V[2][MAXN];
  5. int main() {
  6.     cin >> n;
  7.     for(int i = 0; i < 2; ++i) {
  8.         for(int j = 0; j < n; ++j) {
  9.             cin >> A[i][j];
  10.         }
  11.     }
  12.    
  13.     V[0][0] = A[0][0];
  14.     for(int j = 1; j < n; ++j) {
  15.         V[0][j] = A[0][j] + V[0][j-1];        
  16.     }
  17.  
  18.     V[1][n-1] = A[1][n-1];
  19.     for(int j = n-2; j >= 0; --j) {
  20.         V[1][j] = A[1][j] + V[1][j+1];        
  21.     }
  22.  
  23.    
  24.     int max = 0;
  25.     for(int j = 0; j < n; ++j) {
  26.         int r = V[0][j] + V[1][j];
  27.         if(r > max) {
  28.             max = r;
  29.         }
  30.     }
  31.     cout << max;
  32.    
  33.    
  34.  
  35.    
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top