Skip to content

Commit cc83499

Browse files
authored
Add files via upload
1 parent c815050 commit cc83499

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

Hacker Blocks/Help Ramu.cpp

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/* Hacker Blocks */
2+
/* Title - Help Ramu */
3+
4+
//Ramu often uses public transport. The transport in the city is of two types: cabs and rickshaws. The city has n rickshaws and m cabs, the rickshaws are numbered by integers from 1 to n, the cabs are numbered by integers from 1 to m.
5+
//
6+
//Public transport is not free. There are 4 types of tickets:
7+
//
8+
//A ticket for one ride on some rickshaw or cab. It costs c1 ruppees;
9+
//A ticket for an unlimited number of rides on some rickshaw or on some cab. It costs c2 ruppees;
10+
//A ticket for an unlimited number of rides on all rickshaws or all cabs. It costs c3 ruppees;
11+
//A ticket for an unlimited number of rides on all rickshaws and cabs. It costs c4 ruppees.
12+
//
13+
//Ramu knows for sure the number of rides he is going to make and the transport he is going to use. He asked you for help to find the minimum sum of ruppees he will have to spend on the tickets.
14+
//
15+
//Input Format:
16+
//Each Test case has 4 lines which are as follows:
17+
//
18+
//The first line contains four integers c1,?c2,?c3,?c4 (1?=?c1,?c2,?c3,?c4?=?1000) — the costs of the tickets.
19+
//The second line contains two integers n and m (1<=n,m<=1000) — the number of rickshaws and cabs Ramu is going to use.
20+
//The third line contains n integers ai (0<=ai<=1000) — the number of times Ramu is going to use the rickshaw number i.
21+
//The fourth line contains m integers bi (0<=bi<=1000) — the number of times Ramu is going to use the cab number i.
22+
//
23+
//Constraints:
24+
//1 <= T <= 1000 , where T is no of testcases
25+
//1<=c1,c2,c3,c4<=1000
26+
//1?=?n,?m?=?1000
27+
//0?=?ai?, bi =?1000
28+
//
29+
//Output Format
30+
//For each testcase , print a single number - the minimum sum of rupees Ramu will have to spend on the tickets in a new line.
31+
//
32+
//Sample Input
33+
//2
34+
//1 3 7 19
35+
//2 3
36+
//2 5
37+
//4 4 4
38+
//4 3 2 1
39+
//1 3
40+
//798
41+
//1 2 3
42+
//Sample Output
43+
//12
44+
//1
45+
46+
#include<iostream>
47+
using namespace std;
48+
int main() {
49+
int t,c1,c2,c3,c4,n,m;
50+
int r[1001],c[1001];
51+
cin>>t;
52+
while(t--)
53+
{
54+
cin>>c1>>c2>>c3>>c4;
55+
cin>>n>>m;
56+
int minCost1=0,minCost2=0,minCost3=0,minCost4=0,minCost=0;
57+
for(int i=0;i<n;i++)
58+
cin>>r[i];
59+
for(int i=0;i<m;i++)
60+
cin>>c[i];
61+
for(int i=0;i<n;i++)
62+
minCost1 += min(r[i]*c1,c2);
63+
for(int i=0;i<m;i++)
64+
minCost2 += min(c[i]*c1,c2);
65+
minCost3 = min(minCost1,c3);
66+
minCost4 = min(minCost2,c3);
67+
minCost = min(minCost3+minCost4,c4);
68+
cout<<minCost<<endl;
69+
}
70+
return 0;
71+
}

0 commit comments

Comments
 (0)