PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CC0000068. Đếm số lớn hơn ngưỡng trên đoạn (KQUERY - K-query)
HỌC THEO LỘ TRÌNH
4 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đếm số lớn hơn ngưỡng trên đoạn (KQUERY - K-query)
KQUERY - K-query
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given an array and queries , count the elements with value strictly greater than in the inclusive index range . The array is static.
Input
The first line contains ; the second contains values; the third contains . Each subsequent line contains .
Output
For each query, print the number of qualifying elements on a separate line.
Subtasks
Original constraints: ; ; ; .
- Subtask 1 (20 points): ; ; ; .
- Subtask 2 (30 points): ; ; ; .
- Subtask 3 (50 points): ; ; ; .
Examples
Input
5
5 1 2 3 4
3
2 4 1
4 4 4
1 5 2
Output
2
0
3
Explanation
The three queries return , , and respectively; values equal to do not count.