Igre
시간 제한2초메모리 제한1024 MB
규칙 학습 시간과 플레이 시간의 합이 d분을 넘지 않도록 게임을 골라 여러 번 플레이할 때 얻을 수 있는 평점 합의 최댓값을 구한다.
문제
Kile has returned from a board game fair. He brought home n games. Before playing a game, it is necessary to learn its rules. Learning the rules of the -th game takes minutes. Once the rules are learned, it is possible to play the game. Playing the -th game takes minutes. Each game also has its own rating .
In the coming days, Kile has planned to spend at most minutes on board games. He is interested in finding out the maximum sum of the ratings of the games he can play. Each game can be played an arbitrary number of times.
입력
The first line contains integers and (), the number of games and the time planned to spend on playing games.
The -th of the following lines contains integers , and (, , ), time required to learn the rules, time required to play and the rating of -th game.
출력
In the first and only line, output the maximum sum of the ratings of the games played.