High Score
Medium
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
You play a game consisting of rooms and tunnels. Your initial score is , and each tunnel increases your score by where may be both positive or negative. You may go through a tunnel several times.
Your task is to walk from room to room . What is the maximum score you can get?
Input
The first line has two integers and : the number of rooms and tunnels. The rooms are numbered .
Then, there are lines describing the tunnels. Each line has three integers , and : the tunnel starts at room , ends at room , and it increases your score by . All tunnels are one-way tunnels.
You can assume that it is possible to get from room to room .
Output
Print one integer: the maximum score you can get. However, if you can get an arbitrarily large score, print .
Examples
Input #1
Answer #1
Submissions 109
Acceptance rate 12%