#P8779. [蓝桥杯 2022 省 A] 推导部分和

[蓝桥杯 2022 省 A] 推导部分和

Problem Description

Given an integer sequence A1,A2,ANA_{1}, A_{2}, \cdots A_{N} of length NN, Xiao Lan wants to know the partial sum from index ll to rr, i.e., $\sum\limits_{i=l}^{r} A_i = A_{l} + A_{l+1} + \cdots + A_{r}$.

However, Xiao Lan does not know the value of each number in the sequence. He only knows the values of MM partial sums. The ii-th partial sum is the sum from index lil_{i} to rir_{i}, i.e., $\sum_{j=l_{i}}^{r_{i}} A_j = A_{l_{i}} + A_{l_{i}+1} + \cdots + A_{r_{i}}$, and its value is SiS_{i}.

Input Format

The first line contains 33 integers N,M,QN, M, Q, representing the array length, the number of known partial sums, and the number of queried partial sums.

The next MM lines each contain 33 integers li,ri,Sil_{i}, r_{i}, S_{i}.

The next QQ lines each contain 22 integers ll and rr, representing a partial sum that Xiao Lan wants to know.

Output Format

For each query, output one line containing one integer as the answer. If the answer cannot be determined, output UNKNOWN.

5 3 3
1 5 15
4 5 9
2 3 5
1 5
1 3
1 2
15
6
UNKNOWN

Hint

For 10%10\% of the test cases, 1N,M,Q101 \leq N, M, Q \leq 10, 100Si100-100 \leq S_{i} \leq 100.

For 20%20\% of the test cases, 1N,M,Q201 \leq N, M, Q \leq 20, 1000Si1000-1000 \leq S_{i} \leq 1000.

For 30%30\% of the test cases, 1N,M,Q501 \leq N, M, Q \leq 50, 10000Si10000-10000 \leq S_{i} \leq 10000.

For 40%40\% of the test cases, 1N,M,Q10001 \leq N, M, Q \leq 1000, 106Si106-10^{6} \leq S_{i} \leq 10^{6}.

For 60%60\% of the test cases, 1N,M,Q100001 \leq N, M, Q \leq 10000, 109Si109-10^{9} \leq S_{i} \leq 10^{9}.

For all test cases, 1N,M,Q1051 \leq N, M, Q \leq 10^{5}, 1012Si1012-10^{12} \leq S_{i} \leq 10^{12}, 1liriN1 \leq l_{i} \leq r_{i} \leq N, 1lrN1 \leq l \leq r \leq N. The testdata guarantees that there are no contradictions.

Lanqiao Cup 2022 Provincial Contest A Group, Problem J.

Translated by ChatGPT 5