Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя just_chill_123

Автор just_chill_123, история, 15 месяцев назад, По-английски

I was solving this question which appeared in triology innovation's OA,Can someone tell me what am i doing wrong in this ?

Question goes like this

Given an array A of n elements representing the monsters and an array B of q elements representing the heros. The i−th type of monster is represented by A[i][0] , A[i][1] and A[i][2] which means a monster of the i−th type is present at each integer co-ordinate from A[i][0] to A[i][1] and having a strength of A[i][2]. The i−th type of hero is represented by B[i][0] and B[i][1] which means a hero of strength B[i][1] will appear at the integer point B[i][0] after i seconds. When the i−th hero appears it will destroy each and every monster present at B[i][0] and having a strength less than B[i][1] . For each i you have to determine the number of monsters left after the i−th hero has completed their task.

Input

The first line of input contains two integers N (1≤N≤105) and Q (1≤Q≤105) — the number of monsters and the number of heroes respectively.The next n lines contains 3 integers A[i][0],A[i][1],A[i][2] (1≤A[i][0]≤A[i][1]≤105;1≤A[i][2]≤109) each describing the monsters. The next q lines contains 2 integers B[i][0],B[i][1] (1≤B[i][0]≤105;1≤B[i][1]≤109) each describing the heroes.

Output

Print q space separated integers — the i−th number should be equal to the number of monsters left after the i−th hero has completed their task.

Examples

Input

3 2 1 3 7 2 5 4 4 8 6 3 5 5 8

Output

11 9

Here is My Code:

My Code
  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится