Time limit
2s
Memory limit
128 MB
Jungyu has started a new RPG. A character has two stats: strength (STR) and intelligence (INT). When a character is created, both stats are 1.
There are N quests in the game. Quest i can be completed if the character's strength is at least STR[i] or the character's intelligence is at least INT[i]. Completing the quest gives PNT[i] points that can be spent to increase stats.
Each quest can be completed only once. The quests may be completed in any order, and the points earned from quest rewards may be distributed freely between strength and intelligence.
Find the maximum number of quests Jungyu can complete.
The first line contains the number of quests, N. N is a positive integer not greater than 50.
Each of the next N lines contains STR[i], INT[i], and PNT[i]. All three values are positive integers not greater than 1,000.
Print the maximum number of quests Jungyu can complete on the first line.