Uploaded
ACM _ Zhao minghao
This question is a general basic question, water question, but it is also easy to make mistakes. If you do not understand the question carefully, it is easy to contribute wa. At first, I did not clarify the meaning of the question, I thought it was to directly delete a few digits and find the maximum value. Then I used a sort directly, sorted in the order from large to small, and then output the first M bit, the sample can also pass .. Then I contributed wa several times. Then I took a closer look at the question and asked me to delete M numbers, and then I had the largest number in the original order. In this case, I also had some technical skills;
We can see that some great gods directly use the idea of Dynamic Planning (I am still a DP cainiao ..), Here, two loops are directly nested to find the maximum value in the m + 1 range, and then output the maximum value, and use a variable to mark the position of the maximum value; find the n-m maximum.
This kind of thinking should be mastered and will be used in other places in the future;
The following code is simplified:
# Include <cstdio> # include <cstring> int main () {int T, M, Len, Max; char s [101]; scanf ("% d ", & T); While (t --) {scanf ("% S % d", S, & M); Len = strlen (s); For (INT I = 0, j = 0; m <Len; m ++) // You Can See That J is assigned-1; {max = 0; while (j <= m) // ensure the number of digits {If (s [J]> MAX) {max = s [J]; I = J; // mark the maximum position} J ++; // search down} J = I + 1; printf ("% C", s [I]);} printf ("\ n");} return 0 ;}