Pro.ID22639 TitleGangsters Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22639 AC0 Submit0 Ratio- 时间&空间限制描述N gangsters are going to a restaurant. The i-th gangster comes at the time Ti and has the prosperity Pi. The door of the restaurant has K+1 states of openness expressed by the integers in the range [0, K]. The state of openness can change by one in one unit of time; i.e. it either opens by one, closes by one or remains the same. At the initial moment of time the door is closed (state 0). The i-th gangster enters the restaurant only if the door is opened specially for him, i.e. when the state of openness coincides with his stoutness Si. If at the moment of time when the gangster comes to the restaurant the state of openness is not equal to his stoutness, then the gangster goes away and never returns. The restaurant works in the interval of time [0, T]. The goal is to gather the gangsters with the maximal total prosperity in the restaurant by opening and closing the door appropriately. 输入
输出Description N gangsters are going to a restaurant. The i-th gangster comes at the time Ti and has the prosperity Pi. The door of the restaurant has K+1 states of openness expressed by the integers in the range [0, K]. The state of openness can change by one in one unit of time; i.e. it either opens by one, closes by one or remains the same. At the initial moment of time the door is closed (state 0). The i-th gangster enters the restaurant only if the door is opened specially for him, i.e. when the state of openness coincides with his stoutness Si. If at the moment of time when the gangster comes to the restaurant the state of openness is not equal to his stoutness, then the gangster goes away and never returns. The restaurant works in the interval of time [0, T]. The goal is to gather the gangsters with the maximal total prosperity in the restaurant by opening and closing the door appropriately. Input
Output Print to the output file the single integer -- the maximal sum of prosperity of gangsters in the restaurant. In case when no gangster can enter the restaurant the output should be 0. Sample Input 4 10 20
10 16 8 16
10 11 15 1
10 7 1 8 Sample Output 26 Source 样例输入4 10 20
10 16 8 16
10 11 15 1
10 7 1 8 样例输出26 作者 |