영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)
Problem
Fredrika and her friends are eagerly waiting for their COVID-19 vaccine. They are so anxious to know when they will get their vaccine that they have obtained classified information from the government about the vaccination process. Specifically, they know that there are p_i people ahead of friend i in the queue, and they know how many people get vaccinated each day. Help them calculate when Fredrika and each of her friends will be vaccinated.
Input
The first line contains two integers N and Q (1 ≤ N, Q ≤ 10^5), the number of days where they know how many people get vaccinated, and the number of friends, including Fredrika, who want to know when they will get their vaccine.
The next line contains N integers 0 ≤ k_j ≤ 15, the number of people who get vaccinated on day j (1 ≤ j ≤ N).
Then follows a line with Q integers 0 ≤ p_i ≤ 10^6, the number of people ahead of friend i in the queue.
Output
For each of the Q people, print a line with the day when they will be vaccinated. If someone is so far back in the queue that you don't know when they will be vaccinated, print -1.
Points
Your solution will be tested on several test case groups. To get the points for a group, it must pass all the test cases in the group.
| Group | Point value | Constraints |
|---|---|---|
| 1 | 50 | Q=1, N ≤ 100 |
| 2 | 50 | No additional constraints. |
예제
예제 1
3 3 1 3 5 0 1 5
1 2 3
예제 2
1 1 3 10
-1
예제 3
3 6 2 3 4 7 3 2 10 5 5
3 2 2 -1 3 3