#P4857. [PA 2013] Konduktorzy

[PA 2013] Konduktorzy

Problem Description

There is an infinitely long train with kk ticket inspectors. Each inspector checks aia_i carriages in one operation. Initially, all inspectors are at carriage 00.

Each time, the conductor orders the leftmost inspector with the smallest index to move right by aia_i steps. In total, nn orders are given. Output, for each inspector, which order number corresponds to the final step they make.

Input Format

The first line contains two integers n,kn, k.

The second line contains kk integers aia_i, meaning the length each inspector checks in one operation.

Output Format

Output one line with kk integers. The ii-th integer means which order number corresponds to the final step made by inspector ii.

10 3
3 5 6

10 9 7

Hint

For 100%100\% of the testdata, 1n2×10131 \le n \le 2 \times 10^{13}, 1k1051 \le k \le 10^5, knk \le n, 1ai1051 \le a_i \le 10^5.

Translated by ChatGPT 5