template <typename T> voidread(T &value) { T result = T(0); bool sign = false; char word = getchar(); while (!isdigit(word)) sign |= (word == '-'), word = getchar(); while (isdigit(word)) result = result * 10 + T(word - '0'), word = getchar(); value = sign ? -result : result; }
int stack[NMAX], top, current, a[NMAX], T, n;
intmain() { read(T); while (T--) { bool fail = false; top = 0, current = 0; read(n); for (int i = 1; i <= n; i++) read(a[i]); for (int i = 1; i <= n; i++) { if (a[i] <= current && stack[top] != a[i]) { fail = true; break; } if (stack[top] == a[i]) { top--; continue; } while (current < a[i]) { current++; stack[++top] = current; } top--; } printf("%s\n", fail ? "No" : "Yes"); } return0; }