DJ Gigs
시간 제한8초메모리 제한1024 MB
가중 그래프로 연결된 소수의 공연장과 시간 구간별 보상이 주어질 때, 이동 시간을 고려해 겹치지 않게 공연을 골라 최대 수익을 구한다.
문제
Doug James is an up-and-coming DJ from Graphland who’s had a tough time making it big. This all changed with the release of his latest EP Wiggly Waves, which is the first album in history to go both Platinum and Uranium. With his newfound popularity, Doug (a.k.a. DJ Polygon) needs help with a problem most artists would be lucky to face: deciding which of his many gig offers to take.
There are venues in Graphland, connected by roads. The venues are numbered to . Doug’s house is venue , and he is ready to leave or perform at time .
Doug has gig offers. The -th gig is at venue , runs during the time interval (inclusive start, exclusive end), and pays out cryptocents. Doug can’t take multiple gigs at the same time, and he can’t take gigs while he’s traveling between venues.
Doug is overwhelmed by his newfound fame and many gig requests, and wants your help making as much money as possible.
입력
The first line of the input contains three integers , , and : the number of gigs Doug has been offered, the number of venues in Graphland, and the number of roads connecting these venues.
These integers satisfy , , and .
Then follow lines, each of which has three integers , , and , specifying the -th (bidirectional) road. The -th road connects venues and and it takes time to travel the road in either direction. The values satisfy , , and . Every road has two distinct endpoints, and there is at most one road between any pair of venues.
Then follow lines, each of which has four integers , , , and . This means the -th gig runs from time (inclusive) to (exclusive) at venue , and pays cryptocents. These values satisfy the bounds and .
출력
Output a single integer: the maximum number of cryptocents that DJ Polygon can make by taking on the right gigs.
힌트
In the first sample, There are two gigs at venue and one gig at venue . Doug can either play both gigs at venue for cryptocents, or spend the first units of time traveling to venue and play that gig for cryptocents. He chooses the latter.
In the second sample, Doug makes the most by staying at venue and playing both of those gigs to earn cryptocents.