题解

Another Server

https://ac.nowcoder.com/acm/problem/13812

首先发现规律 一条信道的宽度为连续输入的两个数的和,然后再从头到尾枚举即可。

#include <cstdio>
#include <iostream>
using namespace std;
const int N = 100010;
int a[N], b[N];
int t, n;
int main(void)
{
    scanf("%d", &t);
    while(t -- )
    {
        b[1] = 0x7f7f7f7f;
        scanf("%d", &n);
        for(int i = 0, j = 2; i < n - 1; i ++, j ++ )
        {
            int x, y;
            scanf("%d%d", &x, &y);
            a[j] = x + y;
        }
        for(int i = 2; i <= n; i ++ ) b[i] = min(b[i - 1], a[i]);
        printf("%d\n", b[n]);
    }
    return 0;
}
全部评论

相关推荐

2024-12-23 06:50
门头沟学院 Java
给点吧求求了:3点发的帖子,害怕😰
点赞 评论 收藏
分享
剑桥断刀:找啥工作,牛客找个比如大厂软开或者随便啥的高薪牛马,大把没碰过妹子的技术仔,狠狠拿捏爆金币
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务