#K686. Smallest Absent Integer After Operations
Smallest Absent Integer After Operations
Smallest Absent Integer After Operations
You are given an array A
of N integers and K operations. Each operation is defined by three integers L, R, and X and means that you should add X to every element in the subarray A[L...R]
(1-indexed). After performing all operations, let B be the resulting array. Your task is to find the smallest positive integer that does not occur in B. In other words, find the minimum integer C such that
[ C = \min{ x \in \mathbb{N} \mid x \notin B } ]
Note: It is guaranteed that all operations are applied sequentially, and the operations may overlap.
inputFormat
The first line contains a single integer N representing the number of elements in the array.
The second line contains N space-separated integers representing the elements of the array A
.
The third line contains a single integer K, representing the number of operations.
Each of the following K lines contains three space-separated integers L, R, and X representing an operation that adds X to each element from index L to index R (1-indexed).
outputFormat
Output a single integer: the smallest positive integer that is not present in the final array after all operations.
## sample5
3 4 5 6 7
3
1 3 2
2 4 1
1 5 3
1