(补题 CF 355B) Vasya and Public Transport

原题链接戳我~

题目大意

坐车购票问题

在这一个城市有电车(trolley)以及巴士(bus)两种交通工具,有(c_1,c_2,c_3,c_4)种车票

(c_1):能乘坐一辆电车或巴士一次。

(c_2):能乘坐一辆电车或巴士任意次数。

(c_3):能乘坐电车或巴士多次。

(c_4):能乘坐电车和巴士多次,就是一张通票。

Sample Input

1 3 7 19
2 3
2 5
4 4 4

Sample Output

12

Sample Iutput

4 3 2 1
1 3
798
1 2 3

Sample Output

1

Sample Input

100 100 8 100
3 5
7 94 12
100 1 47 0 42

Sample Output

16

解题思路

emmm.......为了看《天気の子》把当天的训练鸽了。回来把替补一遍

(PS:强力安利一波天气之子)

直接暴力计算四种购票方式,找到最小的花费即可。

代码样例

#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int c1,c2,c3,c4;
    cin >> c1 >> c2 >> c3 >> c4;
    int n,m,s1=0,s2=0;
    cin >> n >> m;
    for(int i=0; i < n; i++)
    {
        int a;
        cin >> a;
        s1+=min(a*c1,c2);
    }
 
 
    for(int i=0; i < m; i++)
    {
        int a;
        cin >> a;
        s2+=min(a*c1,c2);
    }
    cout << min(c4,min(s1,c3)+min(s2,c3)) << endl;
    return 0;
}

原文地址:https://www.cnblogs.com/cafu-chino/p/11794995.html