Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits\stdc++.h>
- using namespace std;
- int main()
- {
- int t;
- scanf("%d", &t);
- while(t--)
- {
- int n, c0, c1, h, i;
- scanf("%d %d %d %d", &n, &c0, &c1, &h);
- char s[n];
- scanf("%s", s);
- int c_zero = 0, c_one = 0;
- for(i = 0; i < n; i++)
- {
- if(s[i] == '0') c_zero++;
- else c_one++;
- }
- //sum = c_zero * min(c0, c1 + h) + c_one * min(c1, c0 + h);
- printf("%d\n", c_zero * min(c0, c1 + h) + c_one * min(c1, c0 + h));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment