Under construction

Still being built. Things may change

Codepowers

Interview

Time limit1.234sMemory limit1024 MB

Summary
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 NN rounds. Hyowon's initial rating XX and the change in rating after each round are given as a sequence AA. The element AiA_i is the rating right after the ii-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.

MM queries are given. For each query, print the number of times the rating was lower than KK from right after round ll to right before round rr.

Input

The first line contains integers NN, MM, KK, and XX. (1≤N≤105,1≤M≤106,−109≤K≤109,−104≤X≤104)(1 \leq N \leq 10^5, 1 \leq M \leq 10^6, -10^9 \leq K \leq 10^9, -10^4 \leq X \leq 10^4)

The second line contains the integers AiA_i that make up the sequence AA. (−104≤Ai≤104)(-10^4 \leq A_i \leq 10^4)

From the third line onward, MM lines follow, each giving the query ljl_j, rjr_j for the jj-th query. (1≤lj<rj≤N+1)(1 \leq l_j < r_j \leq N+1)

Output

Print MM lines, each containing the answer to one query.

Examples1

  1. Example 1

    Input
    10 6 1019 1000
    7 -5 5 8 1 3 6 -7 7 10
    3 6
    1 5
    4 5
    5 9
    3 8
    9 11
    
    Expected output
    3
    4
    1
    2
    3
    0