cf1555C Coin Rows
题意:
有一个两行m列的地图,每个格子都有对应的价值,有a,b两个人,都从左上角到右下角,且都只能向右向下走,a先出发,a每到一个格子,就会获得这个地方的价值,然后b再出发,如果一个格子被a走过,b再走就不会获得价值
问b获得的最大价值
题解:
因为只能向右向下走,如果a从x位置向下走了,那么第一行x位置之后的a就拿不到,而第二行x位置之前的a也拿不到,而这些b可以选其一获得。取这两个部分的最大值
代码:
// Problem: C. Coin Rows
// Contest: Codeforces - Educational Codeforces Round 112 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1555/problem/C
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// Data:2021-08-16 23:55:41
// By Jozky#include <bits/stdc++.h>
#include <unordered_map>
#define debug(a, b) printf("%s = %d\n", a, b);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
clock_t startTime, endTime;
//Fe~Jozky
const ll INF_ll= 1e18;
const int INF_int= 0x3f3f3f3f;
template <typename T> inline void read(T& x)
{T f= 1;x= 0;char ch= getchar();while (0 == isdigit(ch)) {if (ch == '-')f= -1;ch= getchar();}while (0 != isdigit(ch))x= (x << 1) + (x << 3) + ch - '0', ch= getchar();x*= f;
}
template <typename T> inline void write(T x)
{if (x < 0) {x= ~(x - 1);putchar('-');}if (x > 9)write(x / 10);putchar(x % 10 + '0');
}
void rd_test()
{
#ifdef LOCALstartTime= clock();freopen("in.txt", "r", stdin);
#endif
}
void Time_test()
{
#ifdef LOCALendTime= clock();printf("\nRun Time:%lfs\n", (double)(endTime - startTime) / CLOCKS_PER_SEC);
#endif
}
const int maxn= 2e5 + 9;
int a[3][maxn];
int sum[3][maxn];
int main()
{//rd_test();int t;read(t);while (t--) {int n;cin >> n;for (int i= 1; i <= 2; i++) {for (int j= 1; j <= n; j++) {cin >> a[i][j];sum[i][j]= sum[i][j - 1] + a[i][j];}}int minn= INF_int;for (int i= 1; i <= n; i++) {int ans1= sum[1][n] - sum[1][i];int ans2= sum[2][i - 1];minn= min(minn, max(ans1, ans2));}cout << minn << endl;}//Time_test();
}