forked from pratiksh404/nepactober
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbaloons.cpp
More file actions
41 lines (36 loc) · 764 Bytes
/
Copy pathbaloons.cpp
File metadata and controls
41 lines (36 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t--)
{
int g,p,n,sum1=0,sum2=0,ans;
cin>>g>>p>>n;
int a[10][2];
for(int i=0;i<n;i++)
{
for(int j=0;j<2;j++)
{
cin>>a[i][j];
}
}
for(int i=0;i<n;i++)
{
if(a[i][0]==1)
sum1=sum1+g;
if(a[i][1]==1)
sum1=sum1+p;
}
for(int i=0;i<n;i++)
{
if(a[i][0]==1)
sum2=sum2+p;
if(a[i][1]==1)
sum2=sum2+g;
}
ans=sum1>sum2?sum2:sum1;
cout<<ans<<endl;
}
return 0;
}