Skip to content

Commit f44406f

Browse files
Basics of Input/Output
0 parents commit f44406f

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

Cost of balloons.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*echo "# Basic-Programming" >> README.md
2+
git init
3+
git add README.md
4+
git commit -m "first commit"
5+
git branch -M master
6+
git remote add origin https://github.com/AkankshaSingh14/Basic-Programming.git
7+
git push -u origin master*/
8+
9+
10+
import java.util.*;
11+
class TestClass
12+
{
13+
public static void main(String[] args)
14+
{
15+
Scanner input = new Scanner(System.in);
16+
int T = input.nextInt();
17+
while(T > 0)
18+
{
19+
int gBalloon = input.nextInt();
20+
int pBalloon = input.nextInt();
21+
int n = input.nextInt();
22+
int solveA = 0;
23+
int solveB = 0;
24+
for(int i = 0; i < n; i++ )
25+
{
26+
int a = input.nextInt();
27+
int b = input.nextInt();
28+
if (a == 1)
29+
solveA++;
30+
if (b == 1)
31+
solveB++;
32+
}
33+
int x = Math.min(solveA, solveB)*Math.max(gBalloon, pBalloon);
34+
int y = Math.max(solveA, solveB)*Math.min(gBalloon, pBalloon);
35+
System.out.println( x + y );
36+
T--;
37+
}
38+
39+
}
40+
41+
}
42+

0 commit comments

Comments
 (0)