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

Bài tập thuộc lộ trình

1 lộ trình

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 nn tasks requiring tit_i uninterrupted milliseconds each, and mm quiet intervals of lengths LjL_j. At most one task can be completed in each quiet interval, and tasks cannot be split. Maximize completed tasks.

Input

Line 1: n,mn,m. Line 2: nn task durations tit_i. Line 3: mm quiet-interval lengths LjL_j.

Output

Print the maximum number of completed tasks.

Subtasks

  • Subtask 1 (20 points): 1≤n,m≤201\le n,m\le 20; 100000≤ti,Lj≤199999100000\le t_i,L_j\le 199999 for every valid index.
  • Subtask 2 (30 points): 1≤n,m≤30001\le n,m\le 3000; 100000≤ti,Lj≤199999100000\le t_i,L_j\le 199999 for every valid index.
  • Subtask 3 (50 points): 1≤n,m≤2000001\le n,m\le 200000; 100000≤ti,Lj≤199999100000\le t_i,L_j\le 199999 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.