Stacking boxes - MarisaOJ: Marisa Online Judge

Stacking boxes

Time limit: 1000 ms
Memory limit: 256 MB
You are given $n$ boxes, each with a weight denoted by $W_1, W_2, \ldots, W_n$. These boxes can be stacked on top of each other, and each box $i$ has a weight capacity denoted by $C_i$, indicating the maximum weight it can withstand when other boxes are placed on top of it. Your task is to determine the maximum number of boxes that can be stacked together while ensuring that the weight capacity of each box is not exceeded. ### Input - The first line contains an integer $n$. - The second line contains $n$ integer $W_i$. - The third line contains $n$ integer $C_i$. ### Output - Print an integer, the maximum number of boxes can be stacked. ### Constraints - $1 \le n \le 5000$. - $1 \le W_i \le 10^{10}$. - $1 \le C_i \le 10^{10}$. ### Example Input: ``` 3 11 20 30 11 100 10 ``` Output: ``` 2 ```