codevs 3022 西天收费站 x

                     题目描述 Description

唐僧师徒四人终于发现西天就在眼前,但猴子突然发现前面有n个收费站(如来佛太可恶),在每个收费站用不同的方式要交的钱不同,输入每个收费站的每种方法收的钱,输出最少花的钱。

输入描述 Input Description

参见样例

输出描述 Output Description

参见样例

样例输入 Sample Input

样例输入:

4              //四个地点a,b,c,d

3 3 2 2     //3种方法分别是3元,2元,2元,下同

3 100 50 50

1 10000

2 30000 50

样例输出 Sample Output

样例输出:10102

数据范围及提示 Data Size & Hint

数据范围:地点数量<=100,收费<=231,方法数<=100

分类标签 Tags

 
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

int m,n;
long long ans;//地点数量<=100(n),收费<=231,方法数<=100

int main() {
    scanf("%d",&m);
    for (int i=1; i<=m; i++)
    {
        long long  tot,x;
        tot=2147483647;
        scanf("%d",&n);
        for (int j=1; j<=n; j++)
        {
            scanf("%d",&x);
            tot=min(tot,x);//进行比较,将tot赋值为最小的数 
        }
        ans+=tot;//计算和 
    }
    cout<<ans;
    return 0;
}

如果运气好也是错,那我倒愿意错上加错!

❀❀❀❀❀❀❀❀❀❀❀❀❀❀❀❀❀❀❀❀❀

原文地址:https://www.cnblogs.com/zxqxwnngztxx/p/6675545.html