forked from kothariji/competitive-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHCAGMAM1.cpp
38 lines (35 loc) · 813 Bytes
/
HCAGMAM1.cpp
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
#include <iostream>
using namespace std;
int main(void) {
int T,N_pay, B_pay,i,count,present;
int max_count = 0, salary;
char atd[31];
cin>>T;
while(T--){
count = 0;
present = 0;
max_count = 0;
cin>>N_pay>>B_pay;
cin>>atd;
i =0;
while(atd[i]!='\0'){
if (atd[i] == '1'){
count++;
present++;
}
else{
if (max_count < count){
max_count = count;
}
count = 0;
}
i++;
}
if (max_count < count){
max_count = count;
}
salary = (N_pay*present) + (max_count*B_pay);
cout<<salary<<endl;
}
return 0;
}