PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000124. Tuần lộc và xe trượt tuyết (Reindeer and Sleigh)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Tuần lộc và xe trượt tuyết (Reindeer and Sleigh)

Reindeer and Sleigh

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn sleighs, numbered 11 through nn. Sleigh ii requires RiR_i reindeer, and each reindeer may pull at most one sleigh. Pulling multiple sleighs requires the sum of their respective requirements. For each of qq queries giving XjX_j available reindeer, determine the maximum number of sleighs that can be pulled simultaneously. The answer may be zero.

Input

The first line contains n,qn,q. The second line contains nn requirements R1,…,RnR_1,\ldots,R_n. Each of the next qq lines contains one number XjX_j.

Output

Print qq lines, the maximum number of sleighs for each query.

Subtasks

  • Subtask 1 (20 points): 1≤n,q≤251\le n,q\le 25; 1≤Ri≤109; 1≤Xj≤2⋅10141\le R_i\le 10^9;\ 1\le X_j\le 2\cdot10^{14} for 1≤i≤n1\le i\le n, 1≤j≤q1\le j\le q.
  • Subtask 2 (30 points): 1≤n,q≤30001\le n,q\le 3000; 1≤Ri≤109; 1≤Xj≤2⋅10141\le R_i\le 10^9;\ 1\le X_j\le 2\cdot10^{14} for 1≤i≤n1\le i\le n, 1≤j≤q1\le j\le q.
  • Subtask 3 (50 points): 1≤n,q≤2000001\le n,q\le 200000; 1≤Ri≤109; 1≤Xj≤2⋅10141\le R_i\le 10^9;\ 1\le X_j\le 2\cdot10^{14} for 1≤i≤n1\le i\le n, 1≤j≤q1\le j\le q.

Examples

Input

4 3
5 3 11 8
16
7
1000

Output

3
1
4

Explanation

For X=16X=16, choose sleighs 1,2,41,2,4 requiring 5+3+8=165+3+8=16 reindeer; all four require 2727, so the maximum is 33. For X=7X=7, the two smallest requirements sum to 3+5=8>73+5=8>7, so at most one sleigh can be pulled. For X=1000X=1000, all four can be pulled. The answers are 3, 1, and 4.