PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SRD0000018. Đếm phần tử từ ngưỡng (Give Away)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đếm phần tử từ ngưỡng (Give Away)
Give Away
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
You are given a positive integer array . The array changes over time. Process the following operations in their given order:
0 l r c: count the indices in the inclusive interval such that .1 p x: assign . An assignment produces no output.
Every count query refers to the array after all preceding assignments.
Input
The first line contains , followed by initial array values on the next line. The next line contains . Each of the following lines is either 0 l r c or 1 p x.
Output
For each operation of type 0, print the count on its own line. Type 1 produces no output.
Subtasks
- Subtask 1 (10 points): ; ; ; count queries satisfy ; assignments satisfy and .
- Subtask 2 (20 points): ; ; ; count queries satisfy ; assignments satisfy and .
- Subtask 3 (30 points): ; ; ; count queries satisfy ; assignments satisfy and .
- Subtask 4 (40 points): ; ; ; count queries satisfy ; assignments satisfy and .
Examples
Input
5
1 2 3 4 5
3
0 1 5 10
1 2 20
0 1 3 10
Output
0
1
Explanation
Initially every value is below , so the first query returns . After setting , exactly the second element of the interval is at least , so the final query returns .