Codeforces Round #325 (Div. 2) B
来源:互联网 发布:nginx自定义错误页面 编辑:程序博客网 时间:2024/05/29 14:05
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#define inf 0x3f3f3f3fusing namespace std;#define N 100int a[5][N],b[N];int main(){#ifdef CDZSCfreopen("i.txt", "r",stdin);#endifint n;while (~scanf("%d", &n)){memset(a, 0, sizeof(a));for (int k = 1;k<=2;k++)for (int i = 2; i <= n; i++){scanf("%d", &a[k][i]);a[k][i] += a[k][i - 1];}for (int i = 1; i <= n; i++)scanf("%d", &b[i]);int ans = inf;for (int i = 1; i <= n; i++){for (int j = i+1; j <= n; j++){int sum1 = a[1][i] - a[1][1];int sum2 = a[2][n] - a[2][j];int sum3 = a[2][n] - a[2][i];int sum4 = a[1][j] - a[1][1];int sum = sum1 + sum2 +sum3+sum4+ b[i] + b[j];ans = min(ans, sum); }}printf("%d\n", ans);}return 0;}
比赛的时候没有想到,各种DP,搜索。然而他只是一个模拟题而已。先求出前缀和,然后在枚举所有不相交区间的和,求出最小的那个和即可
0 0
- Codeforces Round #325 (Div. 2) B
- Codeforces Round #325 (Div. 2) A && B
- Codeforces Round #325 (Div. 2) B 递推
- Codeforces Round #131 (Div. 2) A B
- Codeforces Round #134 (Div. 2)B. Airport
- Codeforces Round #170 (Div. 2) problem B
- Codeforces Round #173 (Div. 2) Problem B
- Codeforces Round #181 (Div. 2) B. Coach
- Codeforces Round #185 (Div. 2)--A,B
- Codeforces Round #171 (Div. 2) B
- Codeforces Round #169 (Div. 2) B题
- Codeforces Round #188 (Div. 2) B题
- Codeforces Round #192 (Div. 2) B
- Codeforces Round #203 (Div. 2) B. Resort
- Codeforces Round #206 (Div. 2) - b
- Codeforces Round #202 (Div. 2)B-贪心
- Codeforces Round #203 (Div. 2)B
- Codeforces Round #203(Div. 2)B. Resort
- Cookie 和 Session 的区别
- SQL表连接查询(inner join、full join、left join、right join)【转载】
- Codeforces Round #325 (Div. 2) A
- 差分约束系统
- 2015/10/13
- Codeforces Round #325 (Div. 2) B
- JSON解析 Gson解析方式 JSONObject JSONArray
- 复习javascript基础 (1)
- Foundation Kit框架概叙
- 初步18-画星星
- 五个解决方案让MongoDB拥有RDBMS的鲁棒性事务
- Promise/deferred(转)
- HDU 5500 Reorder the Books
- javascript base库