Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define MAXN 101
- using namespace std;
- int n, A[2][MAXN], V[2][MAXN];
- int main() {
- cin >> n;
- for(int i = 0; i < 2; ++i) {
- for(int j = 0; j < n; ++j) {
- cin >> A[i][j];
- }
- }
- V[0][0] = A[0][0];
- for(int j = 1; j < n; ++j) {
- V[0][j] = A[0][j] + V[0][j-1];
- }
- V[1][n-1] = A[1][n-1];
- for(int j = n-2; j >= 0; --j) {
- V[1][j] = A[1][j] + V[1][j+1];
- }
- int max = 0;
- for(int j = 0; j < n; ++j) {
- int r = V[0][j] + V[1][j];
- if(r > max) {
- max = r;
- }
- }
- cout << max;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement