#K84932. Remaining Snacks

    ID: 36529 Type: Default 1000ms 256MiB

Remaining Snacks

Remaining Snacks

You are given \( N \) types of snacks, each having an initial number of pieces. Then, \( M \) students make their choices, each selecting one snack type (specified by a 1-indexed number). When a student selects a snack, one piece is removed from that snack type.

The task is to compute the remaining pieces of each snack type after all student selections have been processed. Mathematically, for each snack type \( i \), the remaining pieces can be expressed as:

\[ \text{remaining}_i = \text{initial}_i - \text{count}_i, \]

where \( \text{count}_i \) is the number of students who chose snack \( i \).

inputFormat

The input is provided via standard input in the following format:

  1. The first line contains two integers \( N \) and \( M \), where \( N \) is the number of snack types and \( M \) is the number of students.
  2. The second line contains \( N \) integers representing the initial number of pieces for each snack type.
  3. The third line contains \( M \) integers representing the snack choices of the students (each choice is a 1-indexed number).

outputFormat

Output \( N \) integers separated by a space, which represent the remaining pieces for each snack type in order from the first to the \( N \)-th snack type.

## sample
5 7
10 5 8 15 20
1 2 3 4 5 1 1
7 4 7 14 19

</p>