#FW0000115. Lịch học liên cơ sở (NTNU Orienteering)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Lịch học liên cơ sở (NTNU Orienteering)
NTNU Orienteering
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
There are campuses and lectures. Lecture takes place at campus from absolute time through (microseconds); it counts only when attended in its entirety. Every pair of campuses has a direct two-way bus travel time; transfers can shorten journeys. You may start early at any campus and depart as soon as a lecture ends. Maximize the number of lectures attended from start to finish.
Input
First line , second line ; next exactly rows (every campus pair exactly once); then rows . Campuses are indexed from .
Output
Print the maximum number of lectures.
Subtasks
-
Subtask 1 (40 points): , , , . All input conditions remain in force.
-
Subtask 2 (60 points): , , , . All input conditions remain in force.
Examples
Input
3
2
0 1 5
1 2 5
0 2 100
0 0 90
2 100 110
Output
2
Explanation
The shortest trip from campus 0 to campus 2 takes 10 through campus 1. After a lecture ending at 90 you reach campus 2 by 100; both lectures are attended.