PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BF0000049. Công ty du lịch (Travel Company)
HỌC THEO LỘ TRÌNH
2 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Công ty du lịch (Travel Company)
Travel Company
Source: LightOJ
Version: Phuoc Hung OJ Extended
Problem Statement
A bus company needs a directed cycle with total income divided by total expense strictly greater than . Every directed road has income and positive expense . Determine whether such a cycle exists.
Input
First line ; then lines . Vertices are zero-based.
Output
Print YES or NO.
Subtasks
- Subtask 1 (20 points): , , ; , , no duplicated directed roads; ; .
- Subtask 2 (30 points): , , ; , , no duplicated directed roads; ; .
- Subtask 3 (50 points): , , ; , , no duplicated directed roads; ; .
Examples
Input
3 3 2
0 1 5 1
1 2 5 1
2 0 5 1
Output
YES
Explanation
The cycle has total income and total expense . Its ratio is , hence YES is correct.