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

#BS0000137. Truy vấn ăn kẹo (Eating Queries)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Truy vấn ăn kẹo (Eating Queries)

Eating Queries

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Timur has nn candies; candy ii contains aia_i units of sugar. For each independent target xjx_j, determine the minimum number of distinct candies whose total sugar is at least xjx_j, or output -1 if even all candies are insufficient. Candies can be reused in different queries.

Input

The first line contains n,qn,q. The second line contains nn values a1,…,ana_1,\ldots,a_n. Each of the next qq lines contains target xjx_j.

Output

Print qq lines in query order: the minimum number of candies, or -1 if impossible.

Subtasks

  • Subtask 1 (20 points): 1≤n≤201\le n\le 20; 1≤q≤201\le q\le 20; 1≤ai≤1041\le a_i\le 10^4 for every 1≤i≤n1\le i\le n; 1≤xj≤2⋅1091\le x_j\le 2\cdot 10^9 for every 1≤j≤q1\le j\le q.
  • Subtask 2 (30 points): 1≤n≤25001\le n\le 2500; 1≤q≤25001\le q\le 2500; 1≤ai≤1041\le a_i\le 10^4 for every 1≤i≤n1\le i\le n; 1≤xj≤2⋅1091\le x_j\le 2\cdot 10^9 for every 1≤j≤q1\le j\le q.
  • Subtask 3 (50 points): 1≤n≤1500001\le n\le 150000; 1≤q≤1500001\le q\le 150000; 1≤ai≤1041\le a_i\le 10^4 for every 1≤i≤n1\le i\le n; 1≤xj≤2⋅1091\le x_j\le 2\cdot 10^9 for every 1≤j≤q1\le j\le q.

Examples

Input

8 7
4 3 3 1 1 4 5 9
1
10
50
14
15
22
30

Output

1
2
-1
2
3
4
8

Explanation

Sorting descending gives 9,5,4,4,3,3,1,19,5,4,4,3,3,1,1; prefix sums for 11 through 88 candies are 9,14,18,22,25,28,29,309,14,18,22,25,28,29,30. Targets 1,10,50,14,15,22,301,10,50,14,15,22,30 require respectively 1,2,−1,2,3,4,81,2,-1,2,3,4,8 candies. In particular, two candies can give at most 1414, so the target 1515 requires three.