PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BF0000052. Bò đi tham quan (Sightseeing Cows)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Bò đi tham quan (Sightseeing Cows)
Sightseeing Cows
Source: Luogu
Version: Phuoc Hung OJ Extended
Problem Statement
There are landmarks, each worth fun , and directed paths of travel time . The cows must make a closed tour visiting at least two distinct landmarks. Maximize total fun on a cycle divided by total travel time; print 0 when no valid tour exists.
Input
First line ; then fun values , then directed edges .
Output
Print the best ratio to two decimals by truncation (do not round); if no valid tour exists print 0.
Subtasks
- Subtask 1 (20 points): , ; ; , ; .
- Subtask 2 (30 points): , ; ; , ; .
- Subtask 3 (50 points): , ; ; , ; .
Examples
Input
5 7
30
10
10
5
10
1 2 3
2 3 2
3 4 5
3 5 2
4 5 5
5 1 3
5 2 2
Output
6.00
Explanation
Cycle accumulates fun and travel time , giving ratio . No other cycle has a greater ratio, so the answer is 6.00.