首先发现规律 一条信道的宽度为连续输入的两个数的和,然后再从头到尾枚举即可。
#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;
}
京公网安备 11010502036488号