Solutions to Codeforces Beta Round #33, A, B, C, D A. What is for dinner?
The problem in fact asks to find out the minimum number in each row. As the number of rows is not quite large, less than 1000, we can adopt an array to record the minimum integer in each row, i.e., whenever a new integer is added to some row, we compare it with the previously stored integer and update the entry with the smaller one. Finally, we add up the minimum integer in each row together, and obtain the possibly "maximum amount of crucians". By comparing it with k, we select the smaller one as the output.
B. String Problem
Well, I got stuck in this problem for a quite long time, until I realized that not only can we change letter A into B or B into A, but also we can change both A and B into some other letter C, which may achieve a smaller sum of money...
This problem can be solved based on graph, where a letter is viewed as a node. The solution can be summarized as the following several steps:
1) Whenever a possible changing from letter A to B...
Solutions to Codeforces Beta Round #33, A, B, C, D
Full text and comments »