Advertisement
skb50bd

UVa 11588 Image Coding

Aug 28th, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main() {
  6.     int c, T, R, C, N, M, max, maxcount;
  7.     char line[20];
  8.     cin >> T;
  9.     for(int Case = 1; Case <= T; Case++) {
  10.         int Alpha[26] = {0};
  11.         cin >> R >> C >> M >> N;
  12.         for(int i = 0; i < R; i++) {
  13.             cin >> line;
  14.             for(int j = 0; line[j]; j++)
  15.                 Alpha[line[j] - 65]++;
  16.         }
  17.         max = 0;
  18.         for(int i = 1; i < 26; i++)
  19.             if(Alpha[max] < Alpha[i]) max = i;
  20.         maxcount = 0;
  21.         for(int i = 0; i < 26; i++)
  22.             if(Alpha[max] == Alpha[i]) maxcount += Alpha[i];
  23.         cout << "Case " << Case << ": " << (maxcount * M) + ((R * C - maxcount) * N) << endl;
  24.     }
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement