题意:有n个孩子排队看病,每次排在第一的孩子进去看病,然后他会哭,最后在他之后的孩子的p值会依次减少vi,vi-1,vi-2……,0,0,0,0,……0。当某个孩子的p<0,则这个孩子也会哭,然后在他之后的所有孩子的p值都会减少di。问,最后医生能够给几个孩子看病。
做法:for套for,暴力模拟
B. Phillip and Trains
题意:3*n的网格,s在最左端某处,每次他可以往右走一步,然后再或上或下走一步或不动。有k个火车从右往左开,每次可以走两步。s先走,火车再走,s又走,火车又走,以此类推。问,s是否能够走到最右端。
做法:dp[r][c][t],在时间t走到r行c列,这个状态能否走到最右断。
C. Alice, Bob, Oranges and Apples
题意:袋子里有x个苹果,y个橘子。a有一个苹果,b有一个橘子。每次你选择一个人把他的水果都给另一个人,然后他再从袋子里拿走他原来的水果数量。问,是否有方法把袋子里的水果刚好拿完。
做法:画一棵树根的三个儿子从左往右结点代表的数对分别是(0,1),(1,1),(1,0)的解答树,只需要判断给出的(x,y)是不是在这棵树中即可。判断方法就是若a>b,则走到(a-b,b),若a<b,则走到(a,b-a),只需要看能否走到(1,1)就知道这个结点是否存在。
D. Lizard Era: Beginning
题意:有n把游戏,每把有三个人的分数,你可以选择任意两个保留。没把都要选择,问,最后能否使得三个人的分数之和一样,且a的分数之和最大。
做法:先暴力出n/2的情况存到map[(b跟a的分数差,c跟a的分数差),(a的分数,把选择情况状压)]里,再暴力出剩下的情况,在map中看能否找到合适的使得他们组合在一起满足要求,不断用a的分数更新最大值即可。
In the game Lizard Era: Beginning the protagonist will travel with three companions: Lynn, Meliana and Worrigan. Overall the game has nmandatory quests. To perform each of them, you need to take exactly two companions.
The attitude of each of the companions to the hero is an integer. Initially, the attitude of each of them to the hero of neutral and equal to 0. As the hero completes quests, he makes actions that change the attitude of the companions, whom he took to perform this task, in positive or negative direction.
Tell us what companions the hero needs to choose to make their attitude equal after completing all the quests. If this can be done in several ways, choose the one in which the value of resulting attitude is greatest possible.
The first line contains positive integer n (1 ≤ n ≤ 25) — the number of important tasks.
Next n lines contain the descriptions of the tasks — the i-th line contains three integers li, mi, wi — the values by which the attitude of Lynn, Meliana and Worrigan respectively will change towards the hero if the hero takes them on the i-th task. All the numbers in the input are integers and do not exceed 107 in absolute value.
If there is no solution, print in the first line "Impossible".
Otherwise, print n lines, two characters is each line — in the i-th line print the first letters of the companions' names that hero should take to complete the i-th task ('L' for Lynn, 'M' for Meliana, 'W' for Worrigan). Print the letters in any order, if there are multiple solutions, print any of them.
3 1 0 0 0 1 0 0 0 1
LM MW MW
7 0 8 9 5 9 -2 6 -8 -7 9 4 5 -4 -9 9 -4 5 2 -6 8 -7
LM MW LM LW MW LM LW
2 1 0 0 1 1 0
Impossible