## https://yukicoder.me/problems/no/2942 class BinaryIndexTree: """ フェニック木(BinaryIndexTree)の基本的な機能を実装したクラス """ def __init__(self, size): self.size = size self.array = [0] * (size + 1) def add(self, x, a): index = x while index <= self.size: self.array[index] += a index += index & (-index) def sum(self, x): index = x ans = 0 while index > 0: ans += self.array[index] index -= index & (-index) return ans def least_upper_bound(self, value): if self.sum(self.size) < value: return -1 elif value <= 0: return 0 m = 1 while m < self.size: m *= 2 k = 0 k_sum = 0 while m > 0: k0 = k + m if k0 < self.size: if k_sum + self.array[k0] < value: k_sum += self.array[k0] k += m m //= 2 if k < self.size: return k + 1 else: return -1 def main(): N, Q, L0 = map(int, input().split()) A = list(map(int, input().split())) queries = [] for _ in range(Q): values = tuple(map(int, input().split())) queries.append(values) max_value = 2 * 10 ** 5 bit_count = BinaryIndexTree(max_value + 1) bit_value = BinaryIndexTree(max_value + 1) for a in A: bit_count.add(a + 1, 1) bit_value.add(a + 1, a) printed = False for values in queries: if values[0] == 1: _, v = values bit_count.add(v + 1, 1) bit_value.add(v + 1, v) elif values[0] == 3: continue elif values[0] == 2: _, l, r = values counts = bit_count.sum(r + 1) - bit_count.sum(l) sum_v = bit_value.sum(r + 1) - bit_value.sum(l) print(counts, sum_v) printed = True if not printed: print("Not Found!") if __name__ == "__main__": main()