codeforces 1555 C. Coin Rows(1300)

链接: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;
	}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值