TCCC '23 Nov P1 - Standard Guidelines

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 1.0s
Memory limit: 128M

Author:
Problem type

At the cardboard box factory, N boxes (1 \le N \le 10^3) are produced every day, each with a side length of S (1 \le S \le 10^3). In order to preserve the company's reputation, the stability of the boxes must be tested according to N standard guidelines. The ith guideline states that a tower with a minimum height of H_i (1 \le H_i \le 10^6) must be achievable by stacking exactly i boxes on top of one another. Each box is perfectly symmetrical, allowing them to be stacked onto of any other box, regardless of their size (a box of size 100 can be stacked on a box of size 1). Given the sizes of N boxes, determine if it is possible to fulfil all N guidelines.

Input Specifications

The first line will consist of a single integer N, the number of boxes and number of guidelines.
The next line will consist of N integers S_i representing the size of the ith box.
The last line will consist of N integers G_i representing the height requirement of the ith guideline.
The height requirement of each guideline will be strictly greater than the previous. After all, what good is a smaller tower made with more boxes?

Output Specifications

Output Yes if all N guidelines can be fulfilled, output No otherwise.

Subtasks

Subtask 1 [2/5]:

  • 1 \le N \le 10
  • 1 \le S_i \le 10

Subtask 2 [3/5]:

  • No further constraints

Sample Input 1

3
3 2 5
1 5 7

Sample Output 1

Yes

Explanation for Sample Output 1

The first guideline can be fulfilled using any of the three boxes as the heights of any of the boxes are greater than 1.
The second guideline can be fulfilled by stacking either box 1 and box 2 for a height of 5, box 1 and box 3 for a height of 8, or box 2 and box 3 for a height of 7, all of which have have a height greater than 5.
The last guideline can be fulfilled stacking all three boxes for a total height of 10, a value larger than the required height of 7.

Sample Input 2

5
9 11 4 7 5
6 19 28 30 35

Sample Output 2

No

Explanation for Sample Output 2

It is impossible to achieve a tower of height 28 using only 3 boxes thus breaking the 3rd guideline.


Comments

There are no comments at the moment.