#P11511. Particle Annihilation in the BLC Experiment
Particle Annihilation in the BLC Experiment
Particle Annihilation in the BLC Experiment
In an international scientific laboratory, scientists are studying the behavior of particles in a Large Linear Collider (BLC). On the BLC, there are n particles placed on a line. Each particle is either an electron (e-, carrying a unit negative charge) or a positron (e+, carrying a unit positive charge). Initially, the i-th particle is placed at coordinate x_i.
Once the experiment begins at time 0, the particles start moving with the same speed of 1. Electrons (e-) move in the negative direction while positrons (e+) move in the positive direction. If at any moment an electron and a positron meet at the same position, they annihilate each other immediately. Note that if the annihilation happens exactly at an observation time point, those particles are not counted in the observation.
The scientists choose m distinct observation times t1, t2, ..., tm. For each observation time, you are to determine the number of particles remaining in the collider after that time (particles annihilated exactly at the observation time are not counted).
Collision Details:
For a positron at position x and an electron at position y with x < y, they approach each other and will meet at time \( t = \frac{y-x}{2} \). Thus, if \( \frac{y-x}{2} \le t \), then the two particles would have annihilated before (or exactly at) the observation time t.
inputFormat
The first line contains two integers n and m, representing the number of particles and the number of observation times respectively.
Then follow n lines. Each of these lines contains an integer x and a string s, where x is the initial position of the particle and s is either e+
(for a positron) or e-
(for an electron).
The last line contains m space-separated integers \( t_1, t_2, \dots, t_m \), representing the observation times.
You may assume that the initial positions are given in arbitrary order and are distinct.
outputFormat
Output m lines. The i-th line should contain the number of particles remaining in the BLC after time \( t_i \) (particles colliding exactly at \( t_i \) are not counted).
sample
3 2
0 e+
5 e-
10 e+
3 6
1
1
</p>