Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main() {
- int c, T, R, C, N, M, max, maxcount;
- char line[20];
- cin >> T;
- for(int Case = 1; Case <= T; Case++) {
- int Alpha[26] = {0};
- cin >> R >> C >> M >> N;
- for(int i = 0; i < R; i++) {
- cin >> line;
- for(int j = 0; line[j]; j++)
- Alpha[line[j] - 65]++;
- }
- max = 0;
- for(int i = 1; i < 26; i++)
- if(Alpha[max] < Alpha[i]) max = i;
- maxcount = 0;
- for(int i = 0; i < 26; i++)
- if(Alpha[max] == Alpha[i]) maxcount += Alpha[i];
- cout << "Case " << Case << ": " << (maxcount * M) + ((R * C - maxcount) * N) << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement