1 Introduction and the main results

In the paper we study the Gusein-Zade version of a generalized secretary problem (see Gusein-Zade 1966). There are many ways for presenting this optimal stopping problem. In the romantic version, instead of interviewing the candidates for a secretary, we have a bachelor who has an occasion to meet a certain number of girls during his bachelorhood and who found out about this number (denoted further by n) in some miraculous way. The bachelor wants to marry one of the k best girls, where k is fixed and less than n. He can not be sure of success as he follows in his live the following principles: in every time he gets to know only one of the girls and after some time he must decide to marry her or to split up. In the latter case he starts to meet the next girl, but later on he can not go back to any girl he decided to split up. The order in which he gets to know the girls is random, thus there are n! equally likely orderings. The bachelor is able to judge only the present girl or the girls he met previously, and he has no idea about the attraction of the future girls. However, we assume that no two girls will turn out equally attractive for him. The problem is to find the best policy for the bachelor, i.e. the policy which maximizes the probability of the marriage to the girl that is one of the k best. In the paper Gusein-Zade (1966) it was proved the following general structure of such a policy:

Proposition 1

(Gusein-Zade (1966)) The best policy for a bachelor who wants to marry one of the k best girls is described by a certain non–decreasing sequence \((s_1, \ldots , s_k)\) of integers with \(l\le s_l<n\) for every \(1\le l\le k\) in the following way: marry the \(i_0\)-th girl, where \(1\le i_0\le n\) is the smallest integer such that there is \(1\le l\le k\) which satisfies:

  1. (i)

    \(s_l<i_0\le s_{l+1}\) (assume \(s_{k+1}:=n-1\)),

  2. (ii)

    the \(i_0\)-th girl is one of the l best of \(i_0\) girls met so far.

If such a number \(i_0\) does not exists, then marry the n-th girl.

Given an arbitrary non–decreasing sequence \((s_1, \ldots , s_k)\) of integers such that \(l\le s_l<n\) for every \(1\le l\le k\), it is natural to ask about the probability of success when using the above described policy with the sequence \((s_1, \ldots , s_k)\). Namely, we would like to know how this probability depends on the elements of this sequence and how to construct a sequence which maximizes this probability.

Definition 1

We call a sequence \((s_1, \ldots , s_k)\) which maximizes the probability of success for the policy described in Proposition 1 as an optimal sequence.

The classical version, i.e. the case \(k=1\), was solved by Lindley (1961) by using equations arising from the principle of dynamic programming. He solved these equations by simple backward recursion and obtained that the only element of an optimal sequence is equal to the smallest integer \(1\le x\le n-1\) such that \(H(n-1)-H(x)\le 1\), where \(H(x):=\sum _{j=1}^{x}1/j\) is the x-th harmonic number, as well as that the probability of success when using the optimal policy with an element \(s_1\) is equal to \(s_1(H(n-1)-H(s_1-1))/n\) (see also Freeman 1983 for the survey paper). The cases \(k=2,3\) were solved by using backward induction and exploiting the existence of an imbedded Markov chain. In the case \(k=2\) the corresponding analytic expressions were stated by Gilbert and Mosteller (1966) and the proof was outlined by Dynkin and Yushkevich (1969). The case \(k=3\) was derived by Quine and Law (1996).

In the present paper, we extended to an arbitrary value of k the formula for an optimal sequence in the following way.

Theorem 1

Let \((s_1, \ldots , s_k)\) be a sequence such that \(s_l=t_l+l-1\) for every \(1\le l\le k\), where each \(t_l\) is defined as the smallest integer \(1\le x\le n-l\) satisfying the inequality

$$\begin{aligned} d_l(x)\le \frac{1}{l}\sum _{i=l}^{k-1}\left( \prod _{j=l+1}^i t_j\right) d_i(t_{i+1})+\frac{1}{l}\left( \prod _{j=l+1}^k t_j\right) \delta _{k,n}, \end{aligned}$$
(1)

where

$$\begin{aligned} \delta _{k,n}:=\left\{ \begin{array}{ll} -\frac{1}{n}\cdot \sum _{j=1}^{n-1}\frac{1}{j},&{}if\;\;k=1,\\ \frac{(n-k)!}{n!},&{}if\;\;k>1, \end{array} \right. \end{aligned}$$
(2)

and the map \(d_l:\{1,\ldots , n-l\}\rightarrow \mathbb {R}\) is defined for each \(0\le l\le k\) as follows:

$$\begin{aligned} d_l(x):=\left\{ \begin{array}{ll} -1+\frac{k\cdot x}{n}+\frac{{n-x-1\atopwithdelims ()k}}{{n\atopwithdelims ()k}}+\frac{x}{{n\atopwithdelims ()k}}\sum \limits _{j=1}^{x}\frac{{n-j-1\atopwithdelims ()k-1}}{j},&{} if\;\;l=0,\\ -\frac{k}{n}-\frac{1}{{n\atopwithdelims ()k}}\sum \limits _{j=1}^{x}\frac{{n-j-1\atopwithdelims ()k-1}}{j},&{}if\;\;l=1,\\ \frac{k\cdot x!\cdot (n-l-x)!}{l\cdot (l-1)\cdot n!}\sum \limits _{j=0}^{l-2}{k-1\atopwithdelims ()j}{n-k\atopwithdelims ()x+l-j-1},&{}if\;\;1<l\le k. \end{array} \right. \end{aligned}$$
(3)

Then \((s_1, \ldots , s_k)\) is an optimal sequence.

In the right side of (1) we use the standard conventions for the empty sum and the empty product and evaluate them to 0 and to 1, respectively. In particular, for \(l=k\) the right side of (1) just equals \(\delta _{k,n}/k\). Hence, the above formula allows to calculate the elements \(s_l (1\le l\le k)\) one by one, from \(l=k\) down to \(l=1\).

In the present paper we also proved the following

Theorem 2

The probability of success for the policy described in Proposition 1 is equal to

$$\begin{aligned} -\sum \limits _{i=0}^{k-1}\left( \prod _{j=1}^i t_j\right) d_i(t_{i+1})-\left( \prod _{j=1}^k t_j\right) \delta _{k,n}, \end{aligned}$$
(4)

where \(t_l:=s_l-l+1\) for \(1\le l\le k\).

The known constructions of the optimal sequence via analytic expressions were presented in the similar form as in Theorem 1 but, as we have mentioned above, only in the cases \(k=1,2,3\). For higher values of k, as well as for some other versions of this problem, the algorithms computing the probability of success and the elements of an optimal sequence can be found in various of papers (see Ajtai et al. 2001; Bruss 1984; Buchbinder et al. 2010; Chan et al. 2015; Dietzal et al. 2011; Feldman and Tennenholtz 2012; Frank and Samuels 1980; Gusein-Zade 1966; Immorlica et al. 2006; Sun et al. 2014). However, in contrast to the analytic solution, these methods apply mechanisms via dynamic or linear programming, and hence only numerically allow to determine the elements of an optimal sequence.

2 The strategy of the proofs

Our proofs are purely elementary and only combinatorial arguments are used. At first, since no two girls are equally attractive for the bachelor, we assign the rank to each girl, which is an integer from 1 to n, i.e. the rank 1 to the best girl, the rank 2 to the next best girl and so on. Then each of the possible n! orderings of the girls defines uniquely a permutation \(\pi \) of the set \(\{1,\ldots , n\}\) such that \(\pi (i)\) is the rank of the i-th girl for every \(i\in \{1,\ldots , n\}\), and conversely, any permutation \(\pi \) of the set \(\{1,\ldots , n\}\) defines in the obvious way the possible ordering of the girls.

Let \(w=(s_1, \ldots , s_k)\) be a non-decreasing sequence such that \(l\le s_l<n\) for every \(l\in \{1,\ldots , k\}\) and let us assume that the policy from Proposition 1 is used with the sequence w. Let \(\pi \) be a permutation defining the ordering of the girls. If the policy successfully chooses a candidate of top k, then we say that \(\pi \) is a lucky permutation corresponding to w. We distinguish the case when there exists \(l\in \{1,\ldots , k\}\) such that for some \(i\in \{1,\ldots , n-1\}\) the following two conditions hold:

  • \(s_l<i\le s_{l+1}\),

  • among the first i girls, there are at most \(l-1\) girls which are more attractive than the i-th girl (equivalently, the set \(\{\pi (1), \ldots , \pi (i)\}\) contains at most l elements which are not greater than \(\pi (i)\)).

We call such a number l a w-threshold of the permutation \(\pi \), and the corresponding number i we call a \((\pi , l, w)\)-element (see also Definition 2 in Sect. 3). Let now assume that the permutation \(\pi \) has a w-threshold. If \(l_0\in \{1,\ldots , k\}\) is the smallest w-threshold of \(\pi \), then the bachelor using the policy will marry to the \(i_0\)-th girl, where \(i_0\) is the smallest \((\pi ,l_0,w)\)-element. Otherwise (i.e. when \(\pi \) has no w-thresholds), the bachelor will marry to the n-th girl. In particular, the set \(\varPi _{w}\) of all lucky permutations corresponding to the sequence w naturally splits into two subsets: the subset \(\varPi _{w,1}\) of permutations having a w-threshold and the subset \(\varPi _{w,2}\) of permutations without w-thresholds. Obviously, the probability of success when using the policy is equal to the ratio

$$\begin{aligned} \frac{|\varPi _{w}|}{n!}=\frac{|\varPi _{w,1}|}{n!}+\frac{|\varPi _{w,2}|}{n!}. \end{aligned}$$

For every \(l\in \{1,\ldots , k\}\) we define the following sets:

$$\begin{aligned} X_l:=\{l,\ldots ,n-1\},\;\;\;X^{(l)}:=X_{k-l+1}\times \ldots \times X_k, \end{aligned}$$

and the set \(X^{(0)}:=\{\epsilon \}\), where \(\epsilon \) is the empty sequence. Further, we refer to the elements of the sets \(X^{(l)}\) as words and to the elements of the sets \(X_l\) as letters.

In Theorem 3 (Sect. 3), we provide for every non-decreasing sequence \(w=(x_1, \ldots , x_k)\in X^{(k)}\) the analytic formulae for the cardinalities of the sets \(\varPi _{w,1}\) and \(\varPi _{w,2}\). To derive the formula for \(|\varPi _{w,1}|\), we consider for each \(1\le l\le k\) and \(x_l<i\le x_{l+1}\) the subset \(S(l,i)\subseteq \varPi _{w,1}\) of all permutations \(\pi \) such that the number l is the smallest w-threshold of \(\pi \) and the number i is the smallest \((\pi ,l,w)\)-element. In particular, we can write

$$\begin{aligned} |\varPi _{w,1}|=\sum \limits _{l=1}^k\sum _{i=x_{l}+1}^{x_{l+1}}|S(l, i)|. \end{aligned}$$

Further, for every \(\pi \in S(l,i)\), we divide the set \(\{\pi (1), \ldots , \pi (i)\}\) into two subsets: the subset of those elements which are not greater than k and the subset of those elements which are greater than k. Conversely, given arbitrarily the sets Y & and \(Y'\) such that

$$\begin{aligned} Y\subseteq \{1,\ldots , k\},\;\;\;Y'\subseteq \{k+1, \ldots , n\},\;\;\;|Y|+|Y'|=i, \end{aligned}$$

we consider the subset \(S(Y, Y', l, i)\subseteq S(l,i)\) of all permutations \(\pi \) for which

$$\begin{aligned} \{1,\ldots , k\}\cap \{\pi (1), \ldots , \pi (i)\}= & {} Y,\\ \{k+1, \ldots , n\}\cap \{\pi (1), \ldots , \pi (i)\}= & {} Y'. \end{aligned}$$

Then, we have:

$$\begin{aligned} |S(l, i)|=\sum \limits _{j=1}^k\sum _{(Y, Y')\in M_j}|S(Y, Y', l, i)|, \end{aligned}$$

where the set \(M_j (j\in \{1,\ldots , k\})\) consists of the pairs \((Y,Y')\) in which \(|Y|=j\). In Proposition 2, we provide the characterization of elements in the set \(S(Y,Y', l,i)\), which allows to find the following formula for its cardinality:

$$\begin{aligned} |S(Y,Y', l,i)|=\min \{|Y|, l\}\cdot (i-l-1)!\cdot (n-i)!\cdot \prod _{j=1}^{l} (x_j-j+1). \end{aligned}$$

We use the above formula to find the cardinality of the set S(li) and, consequently, the following formula for \(|\varPi _{w,1}|\):

$$\begin{aligned} |\varPi _{w,1}|= n!\cdot \sum \limits _{l=1}^k\left( (r_{l-1}(x_l)-r_{l-1}(x_{l+1}))\cdot \prod \limits _{j=1}^l(x_j-j+1)\right) , \end{aligned}$$

where the map \(r_l:\{l+1,\ldots ,n\}\rightarrow \mathbb {R}\) is defined for every integer \(l\le k\) as follows:

$$\begin{aligned} r_l(x):=\left\{ \begin{array}{ll} 0,&{}if\;\;l<0,\\ \frac{1}{x}-\frac{k}{n}-\frac{{n-x-1\atopwithdelims ()k}}{x {n\atopwithdelims ()k}}-\frac{1}{{n\atopwithdelims ()k}}\sum \limits _{j=1}^x\frac{{n-j-1\atopwithdelims ()k-1}}{j},&{}if\;\;l=0,\\ \frac{(x-l-1)!}{x!}\left( 1-\frac{1}{l{n\atopwithdelims ()x}}\sum \limits _{j=0}^l(l-j){k\atopwithdelims ()j}{n-k\atopwithdelims ()x-j}\right) ,&{}if\;\;1\le l\le k. \end{array} \right. \end{aligned}$$
(5)

By using a similar idea as in Proposition 2, we also characterize the elements of the set \(\varPi _{w,2}\) (see Proposition 5), which gives the following formula for \(|\varPi _{w,2}|\):

$$\begin{aligned} |\varPi _{w,2}|=k(n-k-1)!\cdot \prod \limits _{j=1}^k(x_j-j+1). \end{aligned}$$

In Sect. 4, we derive the formula for the elements of an optimal sequence. To this aim, we introduce the notion of an optimal point (see Definition 3) of an arbitrary map \(f:Z\rightarrow \mathbb {R}\), where \(Z\subseteq X^{(l)}\) or \(Z\subseteq X_l\) for some \(l\in \{1,\ldots , k\}\). Next, we define for every \(l\in \{0,1\ldots , k\}\) a map \(T_l:X^{(k-l)}\rightarrow \mathbb {R}\) (see formula (14)), which constitutes a natural generalization of the map

$$\begin{aligned} T:X^{(k)}\rightarrow \mathbb {R},\;\;\;T(w)=\frac{|\varPi _{w,1}|}{n!}+\frac{|\varPi _{w,2}|}{n!}. \end{aligned}$$

We study the maps \(T_l\) in relation to the maps \(c_l, D_l (l\in \{0,\ldots , k\})\) and \(F_{l, w} (l\in \{1,\ldots , k\}, w\in X^{(k-l)})\) defined as follows:

$$\begin{aligned} c_l(x):= & {} d_l(x-l),\;\;\;\;x\in \{l+1,\ldots ,n\},\end{aligned}$$
(6)
$$\begin{aligned} D_l(w):= & {} r_{l-1}(x_1)-T_l(w),\;\;\;\;w\in X^{(k-l)},\end{aligned}$$
(7)
$$\begin{aligned} F_{l,w}(x):= & {} -c_{l-1}(x)-x\cdot D_{l}(w),\;\;\;\;x\in \{l,\ldots ,n-1\}, \end{aligned}$$
(8)

where in (7) the letter \(x_1\) denotes the first letter of a word \(w\in X^{(k-l)}\) or \(x_1:=n-1\) depending on whether \(l<k\) or \(l=k\). In particular, we obtain

$$\begin{aligned} D_0=-T_0=-T. \end{aligned}$$

In Proposition 6, we show how to describe the maps \(D_l\) in terms of the maps \(d_l\). As a result, we obtain for every \(l\in \{1,\ldots , k\}\) that the right side of (1) is equal to

$$\begin{aligned} \frac{D_l\left( w^{(l)}\right) }{l}, \end{aligned}$$

where \(w^{(l)}\in X^{(k-l)}\) arises from the sequence \(w:=(t_1, t_2+1, \ldots , t_k+k-1)\) by deleting the first l letters. In Proposition 7, for any \(l\in \{1,\ldots , k\}\) and \(w\in X^{(k-l)}\), we show that if t is the smallest element \(x\in \{1,\ldots , n-l\}\) such that \(d_l(x)\le D_l(w)/l\), then the number \(t+l-1\) is an optimal point of the map \(F_{l,w}\). Next, we show (Proposition 8) that an arbitrary sequence \(w\in X^{(k)}\) is an optimal point of the map T if and only if for every \(l\in \{1,\ldots , k\}\) the l-th letter of w is an optimal point of the map \(F_{l, w^{(l)}}\). Finally, in Proposition 9, we show that if \(w\in X^{(k)}\) is an optimal point of T, then w must be a non-decreasing sequence. As a simple consequence of Theorem 3 and the above propositions, we obtain our main results (see Sect. 5). The proofs of Propositions 69 are based on various combinatorial identities and on some auxiliary properties of the maps \(r_l, c_l, D_l\) and \(F_{l,w}\). We derive them in Sect. 6.

Further, we use for all \(i,j\in \mathbb {Z}\) the following notations:

  • \([i]:=\{t\in \mathbb {Z}:1\le t\le i\}\),

  • \([i]_0:=[i]\cup \{0\}\),

  • \([i,j]:=\{t\in \mathbb {Z}:i<t\le j\}\),

  • \([\le i]:=\{t\in \mathbb {Z}:t\le i\}\).

3 The formula for the probability of success

Let Sym(n) be the set of all permutations of the set [n]. For every \(\pi \in Sym (n)\) and every \(i\in [n]\) we call the image \(\pi (i)\) the \(\pi \)-rank of the element i. We call the element i a \(\pi \)-candidate if \(\pi (i)\in [k]\). In particular, if the ordering of the girls is defined by a permutation \(\pi \in Sym(n)\), then the bachelor’s win is to marry to the \(i_0\)-th girl, where \(i_0\in [n]\) is an arbitrary \(\pi \)-candidate.

For every \(\pi \in Sym(n)\) and every \(i\in [n]\) we also consider the relative \(\pi \)-rank of the element i, i.e. the number of the elements from the set [i] such that their \(\pi \)-ranks are not greater than \(\pi (i)\); we denote this number by \(\rho _\pi (i)\). In other words, \(\rho _{\pi }(i)\) is the number of those elements from the set \(\pi ([i])\) which are not greater than \(\pi (i)\).

Definition 2

Let \(\pi \in Sym(n)\), \(l\in [k]\) and let \(w=(s_1, \ldots , s_{k})\in X^{(k)}\) be a non-decreasing sequence. We call an arbitrary element \(i\in [s_{l}, s_{l+1}]\) satisfying the inequality \(\rho _\pi (i)\le l\) a \((\pi ,l,w)\)-element. If the set \([s_{l}, s_{l+1}]\) contains at least one \((\pi ,l,w)\)-element, then we call the number l a w-threshold of the permutation \(\pi \). In other words, the element \(l\in [k]\) is a w-threshold of \(\pi \) if there is \(i\in [s_l, s_{l+1}]\) such that \(\rho _\pi (i)\le l\) (as before, we assume \(s_{k+1}:=n-1\)).

Let now assume that the bachelor uses the policy from Proposition 1 with a sequence \(w=(s_1, \ldots , s_k)\) and that the ordering of the girls is defined by a permutation \(\pi \in Sym(n)\). Then \(\pi \) is a lucky permutation corresponding to w if and only if one of the following conditions holds:

  • \(\pi \) has a w-threshold and if \(l_0\in [k]\) is the smallest w-threshold of \(\pi \), then the smallest \((\pi ,l_0,w)\)-element is a \(\pi \)-candidate,

  • \(\pi \) has no w-thresholds and the element n is a \(\pi \)-candidate.

Theorem 3

Let \(w_0=(x_1, \ldots , x_k)\in X^{(k)}\) be a non-decreasing sequence. Then the number of lucky permutations corresponding to \(w_0\) and having a \(w_0\)-threshold is equal to

$$\begin{aligned} n!\cdot \sum \limits _{l=1}^k\left( (r_{l-1}(x_l)-r_{l-1}(x_{l+1}))\cdot \prod \limits _{j=1}^l(x_j-j+1)\right) , \end{aligned}$$

where the maps \(r_l:[l,n]\rightarrow \mathbb {R} (l\in [\le k])\) are defined as in (5). The number of lucky permutations corresponding to \(w_0\) and having no \(w_0\)-thresholds is equal to

$$\begin{aligned} k(n-k-1)!\cdot \prod \limits _{j=1}^k(x_j-j+1). \end{aligned}$$

Proof

Let us fix the integers \(l_0,i_0\) such that \(l_0\in [k]\) and \(i_0\in [x_{l_0},x_{l_0+1}]\). At first, we determine the number of lucky permutations \(\pi \in \varPi _{w_0}\) such that \(l_0\) is the smallest \(w_0\)-threshold of \(\pi \) and \(i_0\) is the smallest \((\pi ,l_0,w_0)\)-element. Let us denote by \(S(l_0, i_0)\) the set of all such permutations.

For every permutation \(\pi \in Sym(n)\), we denote

$$\begin{aligned} \mathcal {X}_\pi :=\pi ([i_0])\cap [k],\;\;\;\mathcal {X}'_\pi :=\pi ([i_0])\cap [k,n]. \end{aligned}$$

Obviously, we have

$$\begin{aligned} \pi ([i_0])=\mathcal {X}_\pi \cup \mathcal {X}'_\pi ,\;\;\;\mathcal {X}_\pi \subseteq [k],\;\;\;\mathcal {X}'_\pi \subseteq [k,n],\;\;\;|\mathcal {X}_\pi |+|\mathcal {X}'_\pi |=i_0. \end{aligned}$$

Moreover, if \(\pi \in S(l_0, i_0)\), then \(\pi \) is a lucky permutation, and hence \(i_0\) is a \(\pi \)-candidate, which implies \(\pi (i_0)\in [k]\) and consequently \(\pi (i_0)\in \mathcal {X}_\pi \). Further, since \(i_0\) is a \((\pi , l_0, w_0)\)-element, we obtain \(\rho _\pi (i_0)\le l_0\), which means that the set \(\pi ([i_0])\) contains at most \(l_0\) elements which are not greater than \(\pi (i_0)\). Since \(\pi (i_0)\in \mathcal {X}_\pi \subseteq [k]\) and \(\mathcal {X}'_\pi \subseteq [k,n]\), all these elements must belong to the set \(\mathcal {X}_\pi \). In particular, if we denote \(\mathcal {X}_\pi :=\{y_1, \ldots , y_{j_0}\}\) for some \(j_0\in [k]\), where \(y_1<y_2<\ldots <y_{j_0}\), then we obtain: \(\pi (i_0)=y_\iota \) for some \(1\le \iota \le \min \{j_0, l_0\}\). Note that \(\iota \) is the relative \(\pi \)-rank of the element \(i_0\).

Let \(Y, Y'\subseteq [n]\) be arbitrary subsets which satisfy the following conditions

$$\begin{aligned} Y\subseteq [k],\;\;\;Y'\subseteq [k,n],\;\;\;|Y|+|Y'|=i_0. \end{aligned}$$
(9)

Let us denote

$$\begin{aligned} S(Y, Y', l_0, i_0):= & {} \{\pi \in S(l_0, i_0):\mathcal {X}_\pi =Y,\;\mathcal {X}'_\pi =Y'\},\\ \mu _{j, l_0}:= & {} \min \{j, l_0\},\;\;\;j\in [k]. \end{aligned}$$

\(\square \)

Proposition 2

For every permutation \(\pi \in S(Y, Y', l_0, i_0)\) the following three conditions hold:

  1. (i)

    \(\pi ([i_0])=Y\cup Y'\),

  2. (ii)

    if \(Y=\{y_1,y_2,\ldots ,y_{j_0}\}\) for some \(j_0\in [k]\) and \(y_1<y_2<\ldots < y_{j_0}\), then there is \(\iota \in [\mu _{j_0, l_0}]\) such that \(\pi (i_0)=y_{\iota }\),

  3. (iii)

    if \(\pi ([i_0-1])=\{y_1',y_2',\ldots ,y'_{i_0-1}\}\) and \(y_1'<y_2'<\ldots <y'_{i_0-1}\), then \(y'_j\in \pi ([x_j])\) for every \(j\in [l_0]\).

Conversely, if the sets \(Y,Y'\) satisfy (9) and a permutation \(\pi \in Sym(n)\) satisfies the conditions (i)-(iii), then \(\pi \in S(Y, Y', l_0, i_0)\).

Proof

(of Proposition 2) Let \(\pi \in S(Y, Y', l_0, i_0)\) be arbitrary. By the above reasoning, the conditions (i)-(ii) directly follow from the equalities \(Y=\mathcal {X}_\pi \) and \(Y'=\mathcal {X}'_\pi \). To justify (iii) let us assume contrary that there is \(j_1\in [l_0]\) such that \(i_1:=\pi ^{-1}(y'_{j_1})\notin [x_{j_1}]\). Since \(\pi (i_1)=y'_{j_1}\in \pi ([i_0-1])\), we have \(i_1<i_0\) and \(\pi ([i_1])\subseteq \pi ([i_0-1])=\{y_1',y_2',\ldots ,y'_{i_0-1}\}\). Thus the set \(\pi ([i_1])\) contains at most \(j_1\) elements which are not greater than \(y'_{j_1}=\pi (i_1)\). Hence the relative \(\pi \)-rank of the element \(i_1\) is not greater than \(j_1\), i.e. \(\rho _{\pi }(i_1)\le j_1\). Since the sequence \((x_{j_1}, \ldots , x_{l_0+1})\) is non–decreasing, we have

$$\begin{aligned}{}[x_{l_0+1}]=[x_{j_1}]\cup \bigcup _{j_1\le j\le l_0}[x_j, x_{j+1}]. \end{aligned}$$

Since \(i_1\in [i_0]\setminus [x_{j_1}]\subseteq [x_{l_0+1}]\setminus [x_{j_1}]\), there is \(j_1\le j_2\le l_0\) such that \(i_1\in [x_{j_2}, x_{j_2+1}]\). But \(\rho _{\pi }(i_1)\le j_1\le j_2\), and hence \(i_1\) is a \((\pi , j_2, w_0)\)-element. Consequently \(j_2\) is a \(w_0\)-threshold of \(\pi \). Since \(j_2\le l_0\) and \(l_0\) is the smallest \(w_0\)-threshold of \(\pi \), we obtain: \(j_2=l_0\). Consequently, the element \(i_1\) is a \((\pi , l_0, w_0)\)-element. Since \(i_1<i_0\), we obtain the contradiction with the assumption that \(i_0\) is the smallest \((\pi , l_0, w_0)\)-element. This justifies the first part of Proposition 2.

Conversely, let \(\pi \in Sym(n)\) be an arbitrary permutation which satisfies (i)-(iii). We show that \(\pi \in S(Y, Y', l_0, i_0)\). By (ii), we have \(\pi (i_0)\in Y\subseteq [k]\), and hence \(i_0\) is a \(\pi \)-candidate. The equalities \(Y=\mathcal {X}_\pi \) and \(Y'=\mathcal {X}'_{\pi }\) directly follows from the definition of the sets \(\mathcal {X}_\pi , \mathcal {X}'_\pi \) as well as from the conditions (9) and from (i). Next, we have \(\pi (i_0)=y_\iota \) for some \(\iota \in [\mu _{j_0, l_0}]\). Since \(\pi ([i_0])=Y\cup Y'\) and every element in \(Y'\) is greater than every element in Y, we see by (ii) that \(\{y_1, \ldots , y_\iota \}\) is the set of all elements from \(\pi ([i_0])\) which are not greater than \(y_\iota =\pi (i_0)\). Thus the relative \(\pi \)-rank of \(i_0\) is equal to \(\iota \). But \(\iota \le l_0\) and hence \(\rho _{\pi }(i_0)\le l_0\). Since \(i_0\in [x_{l_0}, x_{l_0+1}]\), we see that \(i_0\) is a \((\pi , l_0, w_0)\)-element. Thus \(l_0\) is a \(w_0\)-threshold of \(\pi \). To show that \(l_0\) is the smallest \(w_0\)-threshold of \(\pi \), suppose contrary that there is \(l_1<l_0\) such that \(l_1\) is a \(w_0\)-threshold of \(\pi \). Then there is \(i_1\in [x_{l_1}, x_{l_1+1}]\) such that

$$\begin{aligned} \rho _{\pi }(i_1)\le l_1. \end{aligned}$$
(10)

By (iii) we have \(y'_j\in \pi ([x_j])\) for every \(j\in [l_1]\). But for every \(j\in [l_1]\) we have \([x_j]\subseteq [x_{l_1}]\subseteq [i_1]\). Thus we have

$$\begin{aligned} \{y_1', \ldots , y_{l_1}', \pi (i_1)\}\subseteq \pi ([i_1]). \end{aligned}$$
(11)

Since \(i_0\in [x_{l_0}, x_{l_0+1}], i_1\in [x_{l_1}, x_{l_1+1}]\) and \(l_1<l_0\), we have \(i_1<i_0\) and hence, by (iii), we have \(\pi ([i_1])\subseteq \{y_1', \ldots , y_{i_0-1}'\}\). Thus there is \(j_1\in [i_0-1]\) such that

$$\begin{aligned} \pi (i_1)=y'_{j_1}. \end{aligned}$$
(12)

Assuming \(j_1\in [l_1]\), we would have by (iii): \(\pi (i_1)=y'_{j_1}\in \pi ([x_{j_1}])\), and hence \(i_1\in [x_{j_1}]\subseteq [x_{l_1}]\). But, this is impossible as \(i_1\in [x_{l_1}, x_{l_1+1}]\). Thus it must be \(j_1>l_1\), and consequently, we see by (11)–(12) that the set \(\pi ([i_1])\) contains at least \(l_1+1\) elements which are not grater than \(\pi (i_1)\). Thus \(\rho _{\pi }(i_1)\ge l_1+1\) and we have a contradiction with  (10). Hence \(l_0\) is indeed the smallest \(w_0\)-threshold of \(\pi \). To show that \(\pi \in S(Y, Y', l_0, i_0)\), we now need to show that \(i_0\) is the smallest \((\pi , l_0, w_0)\)-element. Suppose contrary that there is \(i_1<i_0\) such that \(i_1\) is a (\(\pi , l_0, w_0)\)-element. We have \(i_1\in [x_{l_0}, x_{l_0+1}]\) and \(\rho _{\pi }(i_1)\le l_0\). Similarly as above, we obtain by (iii) the inclusion \(\{y'_1, \ldots , y'_{l_0}, \pi (i_1)\}\subseteq \pi ([i_1])\). Since \(i_1<i_0\), there is \(j_1\in [i_0-1]\) such that \(\pi (i_1)=y'_{j_1}\). Similarly as above, we show that \(j_1>l_0\). This implies \(\rho _{\pi }(i_1)\ge l_0+1\) and we have a contradiction. Consequently \(i_0\) is indeed the smallest \((\pi , l_0, w_0)\)-element, and hence \(\pi \in S(Y, Y', l_0, i_0)\). \(\square \)

Proposition 3

The number of elements in the set \(S(Y, Y', l_0, i_0)\) is equal to

$$\begin{aligned} \mu _{j_0, l_0}\cdot (i_0-l_0-1)!\cdot (n-i_0)!\cdot \prod _{j=1}^{l_0} (x_j-j+1), \end{aligned}$$

where \(j_0:=|Y|\).

Proof (of Proposition 3)

We use the characterization of the set \(S(Y, Y', l_0, i_0)\) from Proposition 2. By the conditions (i)–(iii), we see that every permutation \(\pi \in S(Y, Y', l_0, i_0)\) can be constructed as follows. At first, we choose arbitrarily an element \(\iota \in [\mu _{j_0, l_0}]\) and define: \(\pi (i_0):=y_\iota \). We can do that in \(\mu _{j_0, l_0}\) ways. Next, for every \(j\in [l_0]\) we choose an element \(i_j\in [x_j]\) and define \(\pi (i_j):=y'_j\). We can do that in \(\prod _{j=1}^{l_0} (x_j-j+1)\) ways. Further, we define the \(\pi \)-ranks from the set

$$\begin{aligned} \widetilde{Y}:=(Y\cup Y')\setminus \{y_\iota , y'_1, \ldots , y'_{l_0}\}=\{y'_{l_0+1}, \ldots , y'_{i_0-1}\}. \end{aligned}$$

Namely, for every \(y\in \widetilde{Y}\) we choose an element \(i_y\in [i_0-1]\setminus \{i_1, \ldots , i_{l_0}\}\) and define \(\pi (i_y):=y\). We can do that in \((i_0-l_0-1)!\) ways. Finally, we define the \(\pi \)-ranks from the set \([n]\setminus (Y\cup Y')\), i.e. for every \(i\in [n]\setminus [i_0]\) we choose an element \(y_i\in [n]\setminus (Y\cup Y')\) and define \(\pi (i):=y_i\). We can do that in \((n-i_0)!\) ways. Hence, the claim directly follows from the above construction. \(\square \)

Proposition 4

The number of elements in the set \(S(l_0, i_0)\) is equal to

$$\begin{aligned} n!\cdot l_0\cdot r_{l_0}(i_0)\cdot \prod _{j=1}^{l_0} (x_j-j+1). \end{aligned}$$

Proof (of Proposition 4)

We have:

$$\begin{aligned} |S(l_0, i_0)|=\sum _{j\in [k]}\sum _{(Y, Y')\in M_j}|S(Y, Y', l_0, i_0)|, \end{aligned}$$

where for every \(j\in [k]\) we define

$$\begin{aligned} M_j:=\{(Y, Y'):Y\subseteq [k],\;\;Y'\subseteq [n]\setminus [k],\;\;|Y|=j,\;\;|Y'|=i_0-j\}. \end{aligned}$$

Since \(|M_j|={k\atopwithdelims ()j}{n-k\atopwithdelims ()i_0-j}\), we obtain from Proposition 3:

$$\begin{aligned} |S(l_0, i_0)|=(i_0-l_0-1)!\cdot (n-i_0)!\cdot \lambda (i_0, l_0)\cdot \prod _{j=1}^{l_0} (x_j-j+1), \end{aligned}$$
(13)

where

$$\begin{aligned} \lambda (i_0, l_0)= & {} \sum _{j=1}^k{k\atopwithdelims ()j}{n-k\atopwithdelims ()i_0-j}\mu _{j, l_0}=\\= & {} \sum _{j=1}^{l_0}{k\atopwithdelims ()j}{n-k\atopwithdelims ()i_0-j} j+\sum _{j=l_0+1}^k{k\atopwithdelims ()j}{n-k\atopwithdelims ()i_0-j}l_0=\\= & {} \sum _{j=0}^{l_0}{k\atopwithdelims ()j}{n-k\atopwithdelims ()i_0-j} j+\sum _{j=0}^k{k\atopwithdelims ()j}{n-k\atopwithdelims ()i_0-j}l_0-\sum _{j=0}^{l_0}{k\atopwithdelims ()j}{n-k\atopwithdelims ()i_0-j}l_0=\\= & {} \sum _{j=0}^k{k\atopwithdelims ()j}{n-k\atopwithdelims ()i_0-j}l_0-\sum _{j=0}^{l_0}(l_0-j){k\atopwithdelims ()j}{n-k\atopwithdelims ()i_0-j}. \end{aligned}$$

From the Vandermonde’s identity, we obtain

$$\begin{aligned} \lambda (i_0, l_0)=l_0{n\atopwithdelims ()i_0}-\sum _{j=0}^{l_0}(l_0-j){k\atopwithdelims ()j}{n-k\atopwithdelims ()i_0-j}=\frac{l_0\cdot n!}{(n-i_0)!\cdot (i_0-l_0-1)!}\cdot r_{l_0}(i_0). \end{aligned}$$

The claim now follows from (13). \(\square \)

Obviously, the number of all lucky permutations from \(\varPi _{w_0}\) which have a \(w_0\)-threshold is equal to \(\sum _{l=1}^k\sum _{i=x_{l}+1}^{x_{l+1}}|S(l, i)|\). We see by Proposition 4 that this double sum can be written as follows

$$\begin{aligned} n!\cdot \sum _{l=1}^k\left( \left( \sum \limits _{i=x_{l}+1}^{x_{l+1}}lr_l(i)\right) \cdot \prod _{j=1}^{l} (x_j-j+1)\right) . \end{aligned}$$

The crucial point for the further study, which also finishes the proof of the first part of Theorem 3, is the observation that the sum \(\sum _{i=x_{l}+1}^{x_{l+1}}lr_l(i)\) in the above expression can be written in a closed form as follows:

$$\begin{aligned} \sum _{i=x_{l}+1}^{x_{l+1}}lr_l(i)=r_{l-1}(x_l)-r_{l-1}(x_{l+1}). \end{aligned}$$

The last equality follows from the identity \(lr_l(x)=r_{l-1}(x)-r_{l-1}(x-1)\) for all \(l\in [\le k]\) and \(x\in [l,n]\), which we derive in Sect. 6 (see Lemma 2 (iii) therein).

To show the second part of Theorem 3, we provide the following characterization of all lucky permutations from \(\varPi _{w_0}\) which have no \(w_0\)-thresholds.

Proposition 5

Let \(\pi \in \varPi _{w_0}\) be an arbitrary lucky permutation without \(w_0\)-thresholds. Then the following two conditions hold:

  1. (i)

    there is \(\iota \in [k]\) such that \(\pi (n)=\iota \),

  2. (ii)

    if \([k+1]\setminus \{\iota \}=\{y_1, \ldots , y_k\}\) and \(y_1<y_2<\ldots <y_{k}\), then \(y_j\in \pi ([x_j])\) for every \(j\in [k]\).

Conversely, if \(\pi \in Sym(n)\) is an arbitrary permutation which satisfies (i)–(ii), then \(\pi \) is a lucky permutation corresponding to \(w_0\) and \(\pi \) has no \(w_0\)-thresholds.

Proof (of Proposition 5)

The condition (i) directly follows from the definition of a lucky permutation. To show (ii), we proceed in the similar way as in the proof of Proposition 2. Namely, suppose contrary that there is \(j_0\in [k]\) such that \(i_0:=\pi ^{-1}(y_{j_0})\notin [x_{j_0}]\). By (i), we have \(i_0\ne n\). Thus \(i_0\in [n-1]\), and since

$$\begin{aligned}{}[n-1]:=[x_{j_0}]\cup \bigcup _{j_0\le j\le k}[x_j, x_{j+1}], \end{aligned}$$

we obtain that there is \(j_0\le j_1\le k\) such that \(i_0\in [x_{j_1}, x_{j_1+1}]\). Since \(y_{j_0}\in [k+1]{\setminus }\{\iota \}\) and \(\iota \notin \pi ([i_0])\), every element in \(\pi ([i_0])\) which is not grater than \(y_{j_0}\) belongs to \([k+1]{\setminus }\{\iota \}\). Since \(\pi (i_0)=y_{j_0}\) and \([k+1]{\setminus } \{\iota \}=\{y_1, \ldots , y_k\}\), we see that the set of all elements from \(\pi ([i_0])\) which are not grater than \(\pi (i_0)\) is contained in the set \(\{y_1, \ldots , y_{j_0}\}\). Thus \(\rho _{\pi }(i_0)\le j_0\le j_1\). Consequently the element \(i_0\) is a \((\pi , j_1, w_0)\)-element. Thus the set \([x_{j_1}, x_{j_1+1}]\) contains a \((\pi , j_1, w_0)\)-element, which means that \(j_1\) is a \(w_0\)-threshold of \(\pi \), contrary to our assumption.

Conversely, let \(\pi \in Sym(n)\) be an arbitrary permutation which satisfies (i)–(ii). We show that \(\pi \) is a lucky permutation corresponding to \(w_0\) and \(\pi \) has no \(w_0\)-thresholds. By (i), it is enough to show that \(\pi \) has no \(w_0\)-thresholds. We proceed in the similar way as in the proof of Proposition 2. Namely, suppose contrary that \(\pi \) has a \(w_0\)-threshold. Then there are \(j_0\in [k]\) and \(i_0\in [x_{j_0}, x_{j_0+1}]\) such that \(\rho _{\pi }(i_0)\le j_0\). By (ii), we have \(y_j\in \pi ([x_j])\) for every \(j\in [j_0]\). But \([x_j]\subseteq [x_{j_0}]\subseteq [i_0]\) for every \(j\in [j_0]\). Hence \(\{y_1, \ldots , y_{j_0}, \pi (i_0)\}\subseteq \pi ([i_0])\). If \(\pi (i_0)\notin [k+1]\), then \(\pi (i_0)>y_{j_0}\) and consequently \(\rho _{\pi }(i_0)\ge j_0+1\). Thus, it must be \(\pi (i_0)\in [k+1]\setminus \{\iota \}\) (note that \(i_0\ne n\) and hence \(\pi (i_0)\ne \iota \)). By (ii), there is \(j_1\in [k]\) such that \(\pi (i_0)=y_{j_1}\). Assuming \(j_1\in [j_0]\), we would have \(\pi (i_0)=y_{j_1}\in \pi ([x_{j_1}])\). Hence \(i_0\in [x_{j_1}]\subseteq [x_{j_0}]\), which is impossible as \(i_0\in [x_{j_0}, x_{j_0+1}]\). Thus it must be \(j_1>j_0\) and consequently \(\rho _{\pi }(i_0)\ge j_0+1\) contrary to our assumption. This finishes the proof of Proposition 5. \(\square \)

By using the conditions (i)-(ii) from Proposition 5, we see that every lucky permutation \(\pi \in \varPi _{w_0}\) without \(w_0\)-thresholds can be constructed as follows. At first, we choose arbitrarily an element \(\iota \in [k]\) and we define: \(\pi (n):=\iota \). We can do that in k ways. Next, we choose for every \(j\in [k]\) an element \(i_j\in [x_j]\) and define \(\pi (i_j):= y_j\). This can be done in \(\prod _{j=1}^{k} (x_j-j+1)\) ways. Finally, we define the \(\pi \)-ranks from the set \([n]\setminus \{\iota , y_1, \ldots , y_{k}\}\), which can be done in \((n-k-1)!\) ways. As a result of this construction, we obtain the required formula. This completes the proof of Theorem 3. \(\square \)

4 The formula for an optimal sequence

Let \(T:X^{(k)}\rightarrow \mathbb {R}\) be the map defined for every \(w=(x_1, \ldots , x_k)\in X^{(k)}\) as follows: \(T(w):=P_1(w)+P_2(w)\), where

$$\begin{aligned} P_1(w):= & {} \frac{|\varPi _{w,1}|}{n!}=\sum \limits _{l=1}^k\left( (r_{l-1}(x_l)-r_{l-1}(x_{l+1}))\cdot \prod \limits _{j=1}^l(x_j-j+1)\right) ,\\ P_2(w):= & {} \frac{|\varPi _{w,2}|}{n!}=\xi _{k,n}\cdot \prod \limits _{j=1}^k(x_j-j+1), \end{aligned}$$

and \(\xi _{k,n}:=k(n-k-1)!/n!\). We see by Theorem 3 that the probability of success for the policy described in Proposition 1 is equal to \(T(w_0)\), where \(w_0=(s_1, \ldots , s_k)\).

Definition 3

If \(f:Z\rightarrow \mathbb {R}\) is a map with \(Z\subseteq X^{(l)}\) or \(Z\subseteq X_l (l\in [k])\), then we call an element \(w_0\in Z\) such that \(f(w_0)\ge f(w)\) for every \(w\in Z\) an optimal point of this map.

In particular, we see that if \(w_0\in X^{(k)}\) is an optimal point of the map T, then \(w_0\) is an optimal sequence (see Definition 1) if and only if it is a non–decreasing sequence. In this section, we show (see Proposition 9) that every optimal point of the map T is indeed a non–decreasing sequence, which implies that every optimal point of T is simultaneously an optimal sequence. We also derive the formula for an optimal point of T (see Propositions 7,8). For this aim, we introduce certain natural generalizations of this map. Namely, for every \(l\in [k]_0\) we define the map \(T_l:X^{(k-l)}\rightarrow \mathbb {R}\) as follows:

$$\begin{aligned} T_l(w):=\sum \limits _{j=1}^{k-l}R_{l,j}(w)\cdot \varGamma _{l,1,j}(w)+\xi _{k,n}\cdot \varGamma _{l,1,k-l}(w), \end{aligned}$$
(14)

where the maps \(R_{l,j},\;\varGamma _{l,j,j'}:X^{(k-l)}\rightarrow \mathbb {R} (l\in [k]_0, j,j'\in [n]_0)\) are defined as follows (in the formula for \(R_{l,j}\) below we assume \(x_{k-l+1}:=n-1\)):

$$\begin{aligned} R_{l,j}((x_1, \ldots , x_{k-l})):= & {} \left\{ \begin{array}{ll} r_{l+j-1}(x_j)-r_{l+j-1}(x_{j+1}),&{}\quad \mathrm{if}\;\;1\le j\le k-l,\\ 0,&{}\quad \mathrm{otherwise}, \end{array} \right. \\ \varGamma _{l,j,j'}((x_1, \ldots , x_{k-l})):= & {} \left\{ \begin{array}{ll} \prod \limits _{t=j}^{j'}(x_t-l-t+1),&{}\quad \mathrm{if}\;\;1\le j\le j'\le k-l,\\ 1,&{}\quad \mathrm{otherwise}. \end{array} \right. \end{aligned}$$

In particular \(T_0=T\) and \(T_k=\xi _{k,n}\).

Let us consider the maps \(D_l (l\in [k]_0)\) defined by (7). In Sect. 6, we derive some properties of these maps (see Lemma 4 therein), which allows to describe them in terms of the maps \(d_l\) defined by (3) in the following way.

Proposition 6

For every \(w=(x_1, \ldots x_k)\in X^{(k)}\) and every \(l\in [k]_0\) we have

$$\begin{aligned} D_l(\sigma ^l(w))=\sum _{i=l}^{k-1}\left( \prod _{j=l+1}^i \widetilde{x}_j\right) d_i(\widetilde{x}_{i+1})+\left( \prod _{j=l+1}^k \widetilde{x}_j\right) \delta _{k,n}, \end{aligned}$$

where \(\sigma :X^{(k-l)}\rightarrow X^{(k-l-1)}\) is a left-shift operator removing the first letter from a non-empty word and \(\widetilde{x}_i:=x_i-i+1\) for every \(i\in [k]\).

Proof

The case \(l=k\) directly follows from the equality \(D_k(\epsilon )=\delta _{k,n}\) (see Lemma 4 (i)). In the case \(l\in [k-1]_0\), we have by Lemma 4 (ii)

$$\begin{aligned} D_l(\sigma ^l(w))=c_l(x_{l+1})+(x_{l+1}-l)D_{l+1}(\sigma ^{l+1}(w)), \end{aligned}$$

where the map \(c_l\) is defined by (6). Hence, since \(c_l(x_{l+1})=d_l(\widetilde{x}_{l+1})\), we can write

$$\begin{aligned} D_l(\sigma ^l(w))=d_l(\widetilde{x}_{l+1})+\widetilde{x}_{l+1}D_{l+1}(\sigma ^{l+1}(w)). \end{aligned}$$

By easy induction on m, we can extend the last formula as follows:

$$\begin{aligned} D_l(\sigma ^l(w))=\sum _{i=l}^m\left( \prod _{j=l+1}^i\widetilde{x}_j\right) d_i(\widetilde{x}_{i+1})+\left( \prod _{j=l+1}^{m+1}\widetilde{x}_j\right) D_{m+1}(\sigma ^{m+1}(w)) \end{aligned}$$
(15)

for every \(l\in [k-1]_0\) and \(m\in [l-1, k-1]\). The claim now follows by taking \(m:=k-1\) in (15). \(\square \)

Let \(F_{l, w} (l\in [k], w\in X^{(k-l)})\) be the maps defined by (8). In the proof of the next proposition, we use some properties of the maps \(c_l\), which we derive in Sect. 6.

Proposition 7

Let \(l\in [k]\) and \(w\in X^{(k-l)}\). If s is the smallest number \(x\in [l-1, n-1]\) such that \(c_l(x+1)\le D_l(w)/l\), then s is an optimal point of the map \(F_{l,w}\). Consequently, if t is the smallest number \(x\in [n-l]\) such that \(d_l(x)\le D_l(w)/l\), then \(t+l-1\) is an optimal point of \(F_{l,w}\).

Proof

For every \(x\in [l-1,n-2]\) the following equality holds:

$$\begin{aligned} F_{l,w}(x+1)-F_{l,w}(x)=l\cdot c_{l}(x+1)-D_l(w). \end{aligned}$$
(16)

Indeed, directly by the definition of the map \(F_{l,w}\), the left side of (16) is equal to \(c_{l-1}(x)-c_{l-1}(x+1)-D_l(w)\), which, by the identity \(lc_l(x+1)=c_{l-1}(x)-c_{l-1}(x+1)\) for all \(x\in [l-1,n-1]\) (see Lemma 3 (iii) in Sect. 6), is equal to the right side of (16). Hence, the first part follows from (16) and from the fact that the map \(c_l\) is non–increasing (see Lemma 3 (iv)). The second part follows now from the equalities \(d_l(x)=c_l(x+l)\) for all \(x\in [n-l]\). \(\square \)

The below proposition is based on the observation that for every word \(w=(x_1, \ldots , x_k)\in X^{(k)}\) and every \(l\in [k]\) there are \(A\in \mathbb {R}_+, B\in \mathbb {R}\) which do not depend on the letter \(x_l\) and such that \(T(w)=A\cdot F_{l, \sigma ^l(w)}(x_l)+B\) (for the proof see Lemma 5 in Sect. 6).

Proposition 8

A sequence \(w=(x_1, \ldots , x_k)\in X^{(k)}\) is an optimal point of the map T if and only if for every \(l\in [k]\) the letter \(x_l\) is an optimal point of the map \(F_{l, \sigma ^l(w)}\).

Proof

Suppose, contrary, that the sequence \(w=(x_1, \ldots , x_k)\) is an optimal point of T and there is \(l\in [k]\) such that the letter \(x_l\) is not an optimal point of \(F_{l, \sigma ^l(w)}\). Let \(x'_l\in X_l\) be an optimal point of \(F_{l, \sigma ^l(w)}\) and let \(w'\in X^{(k)}\) be the word arising from w by replacing the l-th coordinate with \(x'_l\). Since \(\sigma ^l(w')=\sigma ^l(w)\), we have:

$$\begin{aligned} F_{l, \sigma ^l(w')}(x'_l)=F_{l, \sigma ^l(w)}(x'_l)>F_{l, \sigma ^l(w)}(x_l). \end{aligned}$$

By Lemma 5, there are \(A\in \mathbb {R}_+, B\in \mathbb {R}\) such that

$$\begin{aligned} T(w')=A\cdot F_{l, \sigma ^l(w')}(x'_l)+B,\;\;\;T(w)=A\cdot F_{l, \sigma ^l(w)}(x_l)+B. \end{aligned}$$

Consequently \(T(w')>T(w)\), which contradicts with the assumption that w is an optimal point of T.

Conversely, let \(w=(x_1,\ldots , x_k)\in X^{(k)}\) be such that for every \(l\in [k]\) the letter \(x_l\) is an optimal point of the map \(F_{l, \sigma ^l(w)}\). We show that w is an optimal point of T. Let \(v=(y_1, \ldots , y_k)\in X^{(k)}\) be an arbitrary optimal point of the map T. Let us define the words \(w_l\in X^{(k)}\) (\(0\le l\le k\)) as follows: \(w_0:=w, w_k:=v\) and \(w_l:=(y_1, \ldots , y_l, x_{l+1},\ldots , x_k)\) for every \(l\in [k-1]\). In particular, for each \(l\in [k]\) the two words \(w_{l-1}\) and \(w_l\) differ only in the l-th position, which is equal to \(x_l\) in \(w_{l-1}\) and to \(y_l\) in \(w_l\). Hence, by Lemma 5, there are \(A\in \mathbb {R}_+\) and \(B\in \mathbb {R}\) such that

$$\begin{aligned} T(w_{l-1})=A\cdot F_{l, \sigma ^l(w_{l-1})}(x_l)+B,\;\;\;T(w_l)=A\cdot F_{l, \sigma ^l(w_l)}(y_l)+B. \end{aligned}$$

Since the letter \(x_l\) is an optimal point of \(F_{l, \sigma ^l(w)}\) and \(\sigma ^l(w_{l-1})=\sigma ^l(w_l)=\sigma ^l(w)\), we have \(T(w_{l-1})\ge T(w_l)\). Consequently, we obtain the inequalities:

$$\begin{aligned} T(w)=T(w_0)\ge T(w_1)\ge \ldots \ge T(w_k)=T(v). \end{aligned}$$

Since v is an optimal point of T, we have \(T(w)=T(v)\). Thus w is an optimal point of T. \(\square \)

The proof of the next proposition is based on various properties of the maps \(D_l, c_l (l\in [k]_0)\), which we derive in Sect. 6 (see Lemmas 34).

Proposition 9

If \(w=(x_1, \ldots , x_k)\in X^{(k)}\) is an optimal point of the map T, then w is a non–decreasing sequence.

Proof

Let \(w=(x_1, \ldots , x_k)\) be an optimal point of the map T. By Proposition 8, we see that for every \(l\in [k]\) the letter \(x_l\) is an optimal point of the map \(F_{l, \sigma ^l(w)}\). Let us fix \(l\in [k]\setminus \{1\}\) and let us denote \(x:=x_{l-1}, y:=x_l, v:=\sigma ^l(w)\). We have to show that \(x\le y\). We can assume that \(x\ne l-1\) and \(y\ne n-1\). Since x and y are optimal points of \(F_{l-1 yv}\) and \(F_{l, v}\), respectively, we obtain:

$$\begin{aligned} F_{l,v}(y+1)-F_{l,v}(y)\le 0, \;\;\;F_{l-1, yv}(x)-F_{l-1,yv}(x-1)\ge 0. \end{aligned}$$

By (16), we have

$$\begin{aligned} l\cdot c_l(y+1)\le D_l(v),\;\;\;(l-1)\cdot c_{l-1}(x)\ge D_{l-1}(yv). \end{aligned}$$
(17)

Since \(y-l+1>0\), we obtain from the first of the inequalities in (17):

$$\begin{aligned} (y-l+1)\cdot l\cdot c_l(y+1)\le (y-l+1)\cdot D_l(v). \end{aligned}$$
(18)

But from Lemma 4 (ii), we have

$$\begin{aligned} (y-l+1)\cdot D_l(v)=D_{l-1}(yv)-c_{l-1}(y). \end{aligned}$$
(19)

The second inequality in (17) gives:

$$\begin{aligned} D_{l-1}(yv)-c_{l-1}(y)\le (l-1)\cdot c_{l-1}(x)-c_{l-1}(y). \end{aligned}$$
(20)

From (18)–(20), we obtain:

$$\begin{aligned} (y-l+1)\cdot l\cdot c_l(y+1)\le (l-1)\cdot c_{l-1}(x)-c_{l-1}(y). \end{aligned}$$
(21)

Since \(l\cdot c_{l}(y+1)=c_{l-1}(y)-c_{l-1}(y+1)\) (see Lemma 3 (iii)), we obtain

$$\begin{aligned} (y-l+1)\cdot (c_{l-1}(y)-c_{l-1}(y+1))\le (l-1)\cdot c_{l-1}(x)-c_{l-1}(y), \end{aligned}$$

or equivalently:

$$\begin{aligned} (l-1)\cdot (c_{l-1}(x)-c_{l-1}(y+1))\ge (y-l+2)\cdot c_{l-1}(y)-y\cdot c_{l-1}(y+1). \end{aligned}$$
(22)

But the right side of (22) is equal to \(\frac{{n-y-1\atopwithdelims ()k-l+1}}{(l-1)!\cdot {n\atopwithdelims ()k}}\) (see Lemma 3 (v)), which in the case \(y\le n-k+l-2\) is a positive number. Consequently, we have \(c_{l-1}(x)-c_{l-1}(y+1)>0\) in this case. Since the map \(c_{l-1}\) is non–increasing (see Lemma 3 (iv)), we have \(x\le y\). So, we can assume \(y\ge n-k+l-1\). In the case \(l\ge 3\) we have \(D_{l-1}(yv)>0\) by Lemma 4 (iii), and hence, by (17), we obtain in this case: \(c_{l-1}(x)>0\). But then, directly from the definition of the map \(c_{l-1}\), we have

$$\begin{aligned} c_{l-1}(x)=\frac{k\cdot (x-l+1)!\cdot (n-x)!}{(l-1)\cdot (l-2)\cdot n!}\sum \limits _{j=0}^{l-3}{k-1\atopwithdelims ()j}{n-k\atopwithdelims ()x-j-1}>0. \end{aligned}$$

Thus there must be \(j\in [l-3]_0\) such that \(n-k\ge x-1-j\). Consequently \(x\le n-k+1+j\le n-k+l-2<y\). Hence, we can assume \(l=2\). Then by (19), we have \(D_1(yv)-c_1(y)=(y-1)\cdot D_2(v)\) and by the second inequality in (17), we have \(c_1(x)\ge D_1(yv)\). Hence \(c_1(x)-c_1(y)\ge (y-1)\cdot D_2(v)>0\), where the last inequality follows from Lemma 4 (iii). Since the map \(c_1\) is non–increasing, we obtain \(x<y\), which finishes the proof. \(\square \)

5 The proofs of Theorems 12

The main results are a straightforward consequence of Theorem 3 and Propositions 69.

Proof (of Theorem 1)

Let \(w_0:=(s_1, \ldots , s_k)\) be a sequence constructed as in Theorem 1. By Proposition 6, we see that for every \(l\in [k]\) the right side of (1) is equal to \(D_l(\sigma ^l(w_0))/l\). Thus for every \(l\in [k]\) the number \(t_l=s_l-l+1\) is the smallest number \(x\in [n-l]\) which satisfies \(d_l(x)\le D_l(\sigma ^l(w_0))/l\), and hence, by Proposition 7, the number \(s_l\) is an optimal point of the map \(F_{l, \sigma ^l(w_0)}\). By Proposition 8, we obtain that \(w_0\) is an optimal point of the map T. Moreover, the sequence \(w_0\) is non-decreasing by Proposition 9. Hence, we see by the definition of the map T and by Theorem 3 that \(w_0\) is an optimal sequence. \(\square \)

Proof (of Theorem 2)

Let us denote \(w_0:=(s_1, \ldots , s_k)\). By Proposition 6, the expression (4) is equal to \(-D_0(w_0)\), which, by the definition of the map \(D_0\), is equal to \(T_0(w_0)=T(w_0)\). Hence, by the definition of the map T and by Theorem 3, this expression is equal to the probability of success for the policy described in Proposition 1.\(\square \)

6 The auxiliary properties of the maps \(r_l, c_l, D_l\) and \(F_{l, w}\)

Let us define for every \(l\in [k]\) the maps \(a_l,b_l:[n]\rightarrow \mathbb {R}\) as follows:

$$\begin{aligned} a_l(x):=\frac{1}{{n \atopwithdelims ()x}}\sum \limits _{j=0}^l{k\atopwithdelims ()j}{n-k\atopwithdelims ()x-j},\;\;\;b_l(x):=\frac{1}{l{n \atopwithdelims ()x}}\sum \limits _{j=0}^lj{k\atopwithdelims ()j}{n-k\atopwithdelims ()x-j}. \end{aligned}$$

Lemma 1

For all \(x\in [n], l\in [k-1]\) we have:

$$\begin{aligned} a_{l+1}(x)-a_l(x)= & {} \gamma (x,l+1),\end{aligned}$$
(23)
$$\begin{aligned} (l+1)\cdot b_{l+1}(x)-l\cdot b_l(x)= & {} (l+1)\cdot \gamma (x,l+1), \end{aligned}$$
(24)

and for all \(x\in [n-1]\) and \(l\in [k]\) we have:

$$\begin{aligned} a_l(x)-a_{l}(x+1)= & {} \frac{k-l}{n-x}\cdot \gamma (x,l),\end{aligned}$$
(25)
$$\begin{aligned} (x+1)\cdot b_l(x)-x\cdot b_l(x+1)= & {} \frac{(x+1)\cdot (k-l)}{n-x}\cdot \gamma (x,l), \end{aligned}$$
(26)

where \(\gamma (x,l):={k\atopwithdelims ()l}{n-k\atopwithdelims ()x-l}/{n\atopwithdelims ()x}\). In particular, for all \(x\in [1,n]\) and \(l\in [1,k]\) we have

$$\begin{aligned} x\cdot a_{l-1}(x-1)-(x-l)\cdot a_{l-1}(x)= & {} l\cdot a_{l}(x),\end{aligned}$$
(27)
$$\begin{aligned} x\cdot b_{l-1}(x-1)-(x-l)\cdot b_{l-1}(x)= & {} l\cdot b_{l}(x). \end{aligned}$$
(28)

Proof

The identities (23)–(24) directly follow from the definitions of the maps \(a_l, b_l\); the identities (25)–(26) can be easily proved by induction on l. These four identities together with the definitions of the maps \(a_l, b_l\) imply the identities (27)–(28). \(\square \)

Lemma 2

The maps \(r_l\) have the following properties:

  1. (i)

    \(r_l(x)=\frac{(x-l-1)!}{x!}\cdot \left( b_l(x)-a_l(x)+1\right) \) for \(l\in [k]\) and \(x\in [l,n]\),

  2. (ii)

    \(r_0(x)=-\sum _{j=2}^x r_1(j)\) for \(x\in [n]\),

  3. (iii)

    \(l\cdot r_l(x)=r_{l-1}(x-1)-r_{l-1}(x)\) for \(l\in [\le k]\) and \(x\in [l,n]\).

Proof

The item (i) follows directly from the definition of the map \(r_l\). To show (ii), we can write by the definition of \(r_1\):

$$\begin{aligned} r_1(j)=\left( \frac{1}{j-1}-\frac{1}{j}\right) -\frac{(n-j)!\cdot (j-2)!}{n!}\cdot {n-k\atopwithdelims ()j},\;\;j\in [1,n]. \end{aligned}$$

Hence, by the following easily verifiable identity

$$\begin{aligned} \frac{(n-j)!\cdot (j-2)!}{n!}\cdot {n-k\atopwithdelims ()j}=\frac{1}{{n\atopwithdelims ()k}} \left( \frac{{n-j\atopwithdelims ()k}}{j-1}-\frac{{n-(j+1)\atopwithdelims ()k}}{j}\right) -\frac{{n-j-1\atopwithdelims ()k-1}}{j{n\atopwithdelims ()k}}, \end{aligned}$$

we obtain:

$$\begin{aligned} r_1(j)=\left( \frac{1}{j-1}-\frac{1}{j}\right) +\frac{{n-j-1\atopwithdelims ()k-1}}{j{n\atopwithdelims ()k}}- \frac{1}{{n\atopwithdelims ()k}} \left( \frac{{n-j\atopwithdelims ()k}}{j-1}-\frac{{n-(j+1)\atopwithdelims ()k}}{j}\right) ,\;\;j\in [1,n]. \end{aligned}$$

Hence, the item (ii) in the case \(x\in [1,n]\) simply follows from the above equalities. The case \(x=1\) can be directly verified. The item (iii) in the case \(l\le 0\) simply follows from the definition of the map \(r_l\). In the case \(l=1\) it follows from the item (ii). If \(l>1\), then for every \(x\in [l,n]\) we can write by the item (i):

$$\begin{aligned} r_{l-1}(x-1)= & {} \frac{(x-l-1)!}{(x-1)!}(b_{l-1}(x-1)-a_{l-1}(x-1)+1),\\ r_{l-1}(x)= & {} \frac{(x-l)!}{x!}\left( b_{l-1}(x)-a_{l-1}(x)+1\right) . \end{aligned}$$

Now, we can use the equalities (27)–(28) from Lemma 1 and obtain that the difference \(r_{l-1}(x-1)-r_{l-1}(x)\) is equal to

$$\begin{aligned} \frac{(x-l-1)!}{x!}\left( l\cdot b_{l}(x)-l\cdot a_{l}(x)+l\right) =l\cdot r_{l}(x), \end{aligned}$$

which finishes the proof of Lemma 2. \(\square \)

Lemma 3

The maps \(c_l (l\in [k]_0)\) have the following properties:

  1. (i)

    \(c_{l}(x)=\frac{b_{l-1}(x)}{l\cdot l! \cdot {x\atopwithdelims ()l}}\) for \(l\in [1,k], x\in [l,n]\),

  2. (ii)

    \(c_l(x)=r_{l-1}(x)-(x-l)\cdot r_l(x)\) for \(l\in [k]_0, x\in [l,n]\),

  3. (iii)

    \(l\cdot c_{l}(x)=c_{l-1}(x-1)-c_{l-1}(x)\) for \(l\in [k], x\in [l,n]\),

  4. (iv)

    for every \(l\in [k]\) the map \(c_l\) is non–increasing,

  5. (v)

    \((x+1-l)\cdot c_l(x)-x\cdot c_l(x+1)=\frac{{n-x-1\atopwithdelims ()k-l}}{l!\cdot {n\atopwithdelims ()k}}\) for \(l\in [k]\) and \(x\in [l,n-1]\).

Proof

By the definition of the maps \(c_l\), we can write

$$\begin{aligned} c_l(x)=\left\{ \begin{array}{ll} -1+\frac{k\cdot x}{n}+\frac{{n-x-1\atopwithdelims ()k}}{{n\atopwithdelims ()k}}+\frac{x}{{n\atopwithdelims ()k}}\sum \limits _{j=1}^{x}\frac{{n-j-1\atopwithdelims ()k-1}}{j},&{}\mathrm{if}\;\;l=0,\\ -\frac{k}{n}-\frac{1}{{n\atopwithdelims ()k}}\sum \limits _{j=1}^{x-1}\frac{{n-j-1\atopwithdelims ()k-1}}{j},&{}\mathrm{if}\;\;l=1,\\ \frac{k\cdot (x-l)!\cdot (n-x)!}{l\cdot (l-1)\cdot n!}\sum \limits _{j=0}^{l-2}{k-1\atopwithdelims ()j}{n-k\atopwithdelims ()x-j-1},&{}\mathrm{if}\;\;1<l\le k. \end{array} \right. \end{aligned}$$

Hence, the item (i) easily follows from the definition of the map \(b_{l-1}\) and from the identity \(j{k\atopwithdelims ()j}=k{k-1\atopwithdelims ()j-1}\) for \(j\in \mathbb {Z}\). The item (ii) in the case \(l\in \{0,1\}\) directly follows from the definitions of the maps \(c_l, r_{l-1}, r_l\). In the case \(l\in [1,k]\), we can use the item (i) for the left side and Lemma 2 (i) for the right side, and then the claim easily follows from the identities (23)–(24) from Lemma 1. To show the item (iii), we see by (ii) that the difference \(c_{l-1}(x-1)-c_{l-1}(x)\) is equal to:

$$\begin{aligned} (r_{l-2}(x-1)-r_{l-2}(x))-(x-l)\cdot r_{l-1}(x-1)+(x-l+1)\cdot r_{l-1}(x). \end{aligned}$$

By Lemma 2 (iii), we have \(r_{l-2}(x-1)-r_{l-2}(x)=(l-1)\cdot r_{l-1}(x)\). Hence

$$\begin{aligned} c_{l-1}(x-1)-c_{l-1}(x)=x\cdot r_{l-1}(x)-(x-l)\cdot r_{l-1}(x-1). \end{aligned}$$

Again, by Lemma 2 (iii), we have \(r_{l-1}(x-1)=r_{l-1}(x)+l\cdot r_l(x)\), and hence

$$\begin{aligned} c_{l-1}(x-1)-c_{l-1}(x)=l(r_{l-1}(x)-(x-l)\cdot r_l(x)). \end{aligned}$$

The claim now follows from the item (ii). To show (iv), we obtain by the item (iii) that for every \(l\in [k-1]\) and \(x\in [l+1,n]\) the difference \(c_l(x-1)-c_l(x)\) is equal to \((l+1)c_{l+1}(x)\), which is a nonnegative number by the definition of the map \(c_{l+1}\). Hence the map \(c_l\) is non–increasing for every \(l\in [k-1]\). If \(l=k=1\), then the item (iv) follows directly from the definition of the map \(c_l\). If \(l=k>1\), then by the definition of the map \(c_l\), we obtain

$$\begin{aligned} c_k(x)=\frac{(x-k)!}{n(k-1)(x-1)!}-\frac{(n-k)!}{(k-1)n!}. \end{aligned}$$

Hence, we see that also in this case the map \(c_l\) is non-increasing. As for the item (v), the case \(l=1\) follows directly from the item (iii) and from the definition of the map \(c_2\). In the case \(l\in [1,k]\), by the item (i), we obtain that the difference \((x+1-l)c_l(x)-x c_l(x+1)\) is equal to

$$\begin{aligned} \frac{(x-l+1)!}{l (x+1)!}\left( (x+1)b_{l-1}(x)-x b_{l-1}(x+1)\right) , \end{aligned}$$

which is equal to \(\frac{{n-x-1\atopwithdelims ()k-l}}{l!\cdot {n\atopwithdelims ()k}}\) by the equality (26) from Lemma 1. \(\square \)

Lemma 4

The maps \(D_l (l\in [k]_0)\) have the following properties:

  1. (i)

    \(D_k(\epsilon )=\delta _{k,n}\),

  2. (ii)

    \(D_l(w)=(x_1-l)\cdot D_{l+1}(\sigma (w))+c_{l}(x_1)\) for each \(l\in [k-1]_0\) and \(w\in X^{(k-l)}\), where \(x_1\) denotes the first letter of w,

  3. (iii)

    \(D_l(w)>0\) for each \(l\in [1,k]\) and \(w\in X^{(k-l)}\).

Proof

The item (i) directly follows from the definition of the map \(D_k\) and from the formulae (2) and (5) defining, respectively, the number \(\delta _{k,n}\) and the map \(r_{k-1}\). As for the item (ii), for every \(l\in [k-1]_0\) we obtain by Lemma 3 (ii) and by the definitions of the maps \(R_{l,1}, \varGamma _{l,1,1}\):

$$\begin{aligned}&D_l(w)=r_{l-1}(x_1)-T_l(w)\\&\quad =r_{l-1}(x_1)-R_{l,1}(w)\cdot \varGamma _{l,1,1}(w)-\left( \sum \limits _{j=2}^{k-l}R_{l,j}(w)\cdot \varGamma _{l,1,j}(w)+\xi _{k,n}\cdot \varGamma _{l,1,k-l}(w)\right) \\&\quad =c_l(x_1)+r_l(x_2)\cdot (x_1-l)-\left( \sum \limits _{j=2}^{k-l}R_{l,j}(w)\cdot \varGamma _{l,1,j}(w)+\xi _{k,n}\cdot \varGamma _{l,1,k-l}(w)\right) , \end{aligned}$$

where \(x_2\) denotes the second letter of w in the case \(l<k-1\) and \(x_2:=n-1\) in the case \(l=k-1\). In particular, if \(l=k-1\), then \(\varGamma _{l,1,k-l}(w)=\varGamma _{k-1,1,1}(w)=x_1-l\), and hence

$$\begin{aligned} D_l(w)= & {} c_l(x_1)+(x_1-l)\cdot (r_{k-1}(n-1)-\xi _{k,n})\\= & {} c_l(x_1)+(x_1-l)\cdot D_k(\epsilon )=c_l(x_1)+(x_1-l)\cdot D_{l+1}(\sigma (w)). \end{aligned}$$

If \(l<k-1\), then \(\varGamma _{l,1,j}(w)=(x_1-l)\cdot \varGamma _{l,2,j}(w)\) for every \(j\in [k-l]\), and hence

$$\begin{aligned} D_l(w)=c_l(x_1)+r_l(x_2)\cdot (x_1-l)-(x_1-l)\cdot \varLambda , \end{aligned}$$

where

$$\begin{aligned} \varLambda :=\sum \limits _{j=2}^{k-l}R_{l,j}(w)\cdot \varGamma _{l,2,j}(w)+\xi _{k,n}\cdot \varGamma _{l,2,k-l}(w). \end{aligned}$$

Since \(R_{l,j}(w)=R_{l+1,j-1}(\sigma (w))\) and \(\varGamma _{l,2,j}(w)=\varGamma _{l+1,1,j-1}(\sigma (w))\) for every \(j\in [1,k-l]\), we obtain

$$\begin{aligned}&\varLambda =\sum \limits _{j=2}^{k-l}R_{l+1,j-1}(\sigma (w))\cdot \varGamma _{l+1,1,j-1}(\sigma (w))+\xi _{k,n}\cdot \varGamma _{l+1,1,k-l-1}(\sigma (w))=\\&\quad =\sum \limits _{j=1}^{k-l-1}R_{l+1,j}(\sigma (w))\cdot \varGamma _{l+1,1,j}(\sigma (w))+\xi _{k,n}\cdot \varGamma _{l+1,1,k-l-1}(\sigma (w))=T_{l+1}(\sigma (w)). \end{aligned}$$

Consequently, we have:

$$\begin{aligned}&D_l(w)=c_l(x_1)+(x_1-l)\cdot r_l(x_2)-(x_1-l)\cdot T_{l+1}(\sigma (w))=\\&\quad =c_l(x_1)+(x_1-l)(r_l(x_2)-T_{l+1}(\sigma (w)))=c_l(x_1)+(x_1-l)\cdot D_{l+1}(\sigma (w)), \end{aligned}$$

which finishes the proof of the item (ii). The item (iii) directly follows from the items (i)–(ii) and from the inequalities \(c_l(x)\ge 0\) for all \(l\in [1,k], x\in [l,n]\). \(\square \)

Lemma 5

Let \(w=(x_1, \ldots , x_k)\in X^{(k)}\) be arbitrary. Then for every \(l\in [k]\) there exist \(A\in \mathbb {R}_+, B\in \mathbb {R}\) which do not depend on the letter \(x_l\) and such that \(T(w)=A\cdot F_{l, \sigma ^l(w)}(x_l)+B\).

Proof

Let us fix \(l\in [k]\) and let us define \(A:=\varGamma _{0,1,l-1}(w)\). Then we see by the definition of the map \(\varGamma _{0,1,l-1}\) that A does not depend on \(x_l\) and \(A>0\). By the definition of the map \(T=T_0\), we have \(T(w)=B_1+B_2+B_3\), where

$$\begin{aligned} B_1:= & {} \sum _{j=1}^{l-2}R_{0,j}(w)\cdot \varGamma _{0,1,j}(w),\\ B_2:= & {} \sum _{j=l-1}^lR_{0,j}(w)\varGamma _{0,1,j}(w)=AR_{0,l-1}(w)+R_{0,l}(w)\varGamma _{0,1,l}(w),\\ B_3:= & {} \sum _{j=l+1}^{k}R_{0,j}(w)\varGamma _{0,1,j}(w)+\xi _{k,n}\varGamma _{0,1,k}(w). \end{aligned}$$

By the definitions of the maps \(R_{0,j}, \varGamma _{0,1,j} (j\in [l-2])\), we see that \(B_1\) does not depend on \(x_l\). Since \(\varGamma _{0,1,j}(w)=A(x_l-l+1)\varGamma _{0,l+1,j}(w)\) for every \(j\in [l-1,k]\), we obtain \(T(w)=B_1+AB_2'+AB_3'\), where

$$\begin{aligned} B_2':= & {} R_{0, l-1}(w)+(x_l-l+1)\cdot R_{0,l}(w),\\ B_3':= & {} (x_l-l+1)\cdot B_4,\\ B_4:= & {} \sum \limits _{j=l+1}^k R_{0,j}(w)\cdot \varGamma _{0,l+1,j}(w)+\xi _{k,n}\cdot \varGamma _{0,l+1,k}(w). \end{aligned}$$

Next, by the definitions of the maps \(R_{0,l-1}, R_{0,l}\) and by Lemma 3 (ii), we obtain

$$\begin{aligned} B_2'=B_2''-c_{l-1}(x_l)-x_l\cdot r_{l-1}(x_{l+1}), \end{aligned}$$

where \(B_2'':=r_{l-2}(x_{l-1})+(l-1)\cdot r_{l-1}(x_{l+1})\) does not depend on \(x_l\). Further, since \(R_{0,j}(w)=R_{l, j-l}(\sigma ^l(w))\) and \(\varGamma _{0,l+1,j}(w)=\varGamma _{l,1, j-l}(\sigma ^l(w))\) for every \(j\in [l-1,k]\), we obtain

$$\begin{aligned} B_4= & {} \sum \limits _{j=l+1}^k R_{l,j-l}(\sigma ^l(w))\cdot \varGamma _{l,1,j-l}(\sigma ^l(w))+\xi _{k,n}\cdot \varGamma _{l,1,k-l}(\sigma ^l(w))\\= & {} \sum \limits _{j=1}^{k-l} R_{l,j}(\sigma ^l(w))\cdot \varGamma _{l,1,j}(\sigma ^l(w))+\xi _{k,n}\cdot \varGamma _{l,1,k-l}(\sigma ^l(w))=T_l(\sigma ^l(w)). \end{aligned}$$

Hence

$$\begin{aligned} B_3'=(x_l-l+1)\cdot B_4=x_l\cdot T_l(\sigma ^l(w))-B_3'', \end{aligned}$$

where \(B_3'':=(l-1)\cdot T_l(\sigma ^l(w))\) does not depend on \(x_l\). We can now write

$$\begin{aligned} T(w)= & {} B_1+A\cdot (B_2'+B_3')=\\= & {} B_1+A\cdot (B_2''-c_{l-1}(x_l)-x_l\cdot r_{l-1}(x_{l+1})+x_l\cdot T_l(\sigma ^l(w))-B_3'')=\\= & {} B_1+A\cdot (B_2''-c_{l-1}(x_l)-x_l\cdot D_l(\sigma ^l(w))-B_3'')=\\= & {} B_1+A\cdot (B_2''-B_3'')+A\cdot F_{l,\sigma ^l(w)}(x_l)=B+A\cdot F_{l,\sigma ^l(w)}(x_l), \end{aligned}$$

where \(B:=B_1+A\cdot (B_2''-B_3'')\) does not depend on \(x_l\). \(\square \)

7 Conclusion

In the present paper, we obtained the analytic formulae for an optimal sequence \((s_1, \ldots , s_k)\) in the Gusein-Zade version Gusein-Zade (1966) of a generalized secretary problem. In this problem, the interviewer would like to choose one of the k best of n candidates arriving in random order and the stopping rule is based on the relative ranks of the successive arrivals. For any sequence \((s_1, \ldots , s_k)\) describing the optimal policy, we also found the analytic formula for the probability of success when using the policy with this sequence. Our original approach is purely elementary and bases on the combinatorial analysis of the problem. The obtained formulae reveal the possibility of an extension to an arbitrary value of k for closed expressions describing the elements of an optimal sequence. Until now such expressions were derived only for \(k\le 3\). Since the maps \(d_l\) in the inequalities (1) describing the optimal sequence are all non-increasing, our formula reduces the determination of elements in this sequence to solving a system of k equations. In other words, we need to solve a recurrence with the number of steps bounded by k, which is substantially more advantageous than the implicit solution via computing the optimum from the known mechanism of dynamic or linear programming. On the other hands, in recent years, the linear programming approach was discovered to analyze a broader class of secretary problems. For example, in Buchbinder et al. (2010) the authors consider a so-called J-choice K-best secretary problem (the case \(J=1\) was the subject of the present paper), where finding of an optimal solution reduces to solving the corresponding linear program. In Chan et al. (2015) the authors use linear programming but to the so-called continuous and infinite models of the secretary problem (see also Bruss 1984; Immorlica et al. 2006). In Sun et al. (2014) even a more general problem is studied via this technique – a so called shared Q-queue J-choice K-best secretary problem. Therefore, it seems natural to analyze and develop our combinatorial approach also for wider classes of secretary problems, which might result in finding some simplifications in the corresponding formulae. The construction of the optimal sequence from Theorem 1 could also be applied in the study of the limits \(\tau _l(k):=\lim _{n\rightarrow \infty }s_l/n\) (\(1\le l\le k\)) and their behaviour. This could help in solving some (according to our knowledge) open questions concerning these limits, such as (see also Frank and Samuels 1980; Freeman 1983): Is it true that \(\tau _1(k)\) monotonically decreases with k?