PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000270. Kế hoạch tài chính (Financial Planning)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Kế hoạch tài chính (Financial Planning)
Financial Planning
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
You need at least euros net to retire. Starting with no cash, you may borrow any amount interest-free. Each of investment opportunities can be purchased once for euros and returns euros per day. Choose any subset at the start and repay the entire loan after an integer number of days. Find the earliest day at which at least euros remain.
Input
The first line contains . Each of the next lines contains , daily earnings followed by initial cost.
Output
Print the minimum number of days.
Subtasks
- Subtask 1 (20 points): ; ().
- Subtask 2 (30 points): ; (); ; .
- Subtask 3 (50 points): ; ().
Examples
Input 1
2 5
4 10
10 15
Output 1
2
Explanation
After two days the second option nets 20-15=5. Neither option is profitable after one day.