PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000045. Tuần lễ tân sinh viên (Frosh Week 2)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tuần lễ tân sinh viên (Frosh Week 2)
Frosh Week 2
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
Zac has tasks requiring uninterrupted milliseconds each, and quiet intervals of lengths . At most one task can be completed in each quiet interval, and tasks cannot be split. Maximize completed tasks.
Input
Line 1: . Line 2: task durations . Line 3: quiet-interval lengths .
Output
Print the maximum number of completed tasks.
Subtasks
- Subtask 1 (20 points): ; for every valid index.
- Subtask 2 (30 points): ; for every valid index.
- Subtask 3 (50 points): ; for every valid index.
Examples
Input
5 4
150000 100000 160000 100000 180000
190000 170000 140000 160000
Output
4
Explanation
Four intervals accommodate jobs of duration 100000, 100000, 150000 and 160000, respectively. There are only four intervals, hence four is the maximum.