Codepowers
InterviewTime limit1.234sMemory limit1024 MB
Given an initial rating X and per-round changes A, count how many ratings in each query range [l, r) fall below K.
- Level
Medium6 of 10
- Topics
- Prefix sum, Sorting, Segment tree
- Solved
- No attempts yet
Problem
Hyowon is a member of Codepowers, a well-known overseas online judge. Codepowers gives its members a rating system. Each time a member joins a weekly round, the site assigns a rating.
Hyowon has taken part in rounds. Hyowon's initial rating and the change in rating after each round are given as a sequence . The element is the rating right after the -th round minus the rating right before that round.
Hyowon did not earn the rating expected, and wants to know when the rating fell below the target.
queries are given. For each query, print the number of times the rating was lower than from right after round to right before round .
Input
The first line contains integers , , , and .
The second line contains the integers that make up the sequence .
From the third line onward, lines follow, each giving the query , for the -th query.
Output
Print lines, each containing the answer to one query.