Question: Chinese question, you know...
Ideas:Create two arrays, one tag, and one answer (that is, the fastest task point to be processed). When you input data, Mark and change the location that already has a task, and find a maximum number of Max. Then, from Max + 1, start from big to small, and use temp to define the serial number without a task. If it is not marked, define the answer here as temp.
Click the link to open the question
Code:
# Include <stdio. h> # include <string. h> # define maxn 200005int vis [maxn], ANS [maxn]; int main () {int t, n, m, I, j, Q; scanf ("% d", & T); While (t --) {int A; memset (VIS, 0, sizeof (VIS); memset (ANS, 0, sizeof (ANS); int K = 0; int max = 0; scanf ("% d", & N, & M); for (I = 1; I <= N; I ++) {scanf ("% d", & A); vis [a] = 1; if (max <A) max = ;} int temp = MAX + 1; for (I = max; I> 0; I --) {If (vis [I]) ans [I] = temp; else temp = I ;} While (M --) {scanf ("% d", & Q); If (! Vis [Q]) {printf ("% d \ n", q) ;}elseprintf ("% d \ n", ANS [Q]) ;}} return 0 ;}