链接:https://codeforces.com/problemset/problem/1555/C
题意:自己翻
题解:
就遍历一遍,处理上下2行的值,每次取最大存,然后输出这些值的最小的;具体看代码
代码:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100005];
int b[100005];
int c[100005];
int main()
{
int t;
cin >> t;
while (t--)
{
int m;
cin >> m;
memset(a, 0, sizeof(a));
memset(b, 0, sizeof(b));
memset(c, 0, sizeof(c));
for (int j = 1; j <= m; j++)
{
int x;
cin >> x;
a[j] = a[j - 1] + x;
}
for (int j = 1; j <= m; j++)
{
int x;
cin >> x;
b[j] = b[j - 1] + x;
}
a[0] = INT_MAX;
b[0] = INT_MAX;
a[m+1] = INT_MAX;
b[m+1] = INT_MAX;
int ans = INT_MAX;
for (int i = 2; i <= m; i++)
{
c[i] = max(a[m] - a[i], b[i - 1]);
}
c[1] = a[m] - a[1];
sort(c+1, c + m+1);
cout << c[1] << endl;
}
}
|