Print? # Include <stdio. h>
# Include <string. h>
# Define N 1000010
Int wa [N], wb [N], wv [N], ws [N];
Int rank [N], height [N];
Int sa [N], r [N];
Int abs (int x)
{
Return x <0? -X: x;
}
Int cmp (int * r, int a, int B, int l)
{
Return r [a] = r [B] & r [a + l] = r [B + l];
}
Void da (int * r, int * sa, int n, int m)
{
Int I, j, p, * x = wa, * y = wb, * t;
For (I = 0; I <m; I ++) ws [I] = 0;
For (I = 0; I <n; I ++) ws [x [I] = r [I] ++;
For (I = 1; I <m; I ++) ws [I] + = ws [I-1];
For (I = n-1; I> = 0; I --) sa [-- ws [x [I] = I;
For (p = 1, j = 1; p <n; j * = 2, m = p)
{
For (p = 0, I = n-j; I <n; I ++) y [p ++] = I;
For (I = 0; I <n; I ++) if (sa [I]> = j) y [p ++] = sa [I]-j;
For (I = 0; I <n; I ++) wv [I] = x [y [I];
For (I = 0; I <m; I ++) ws [I] = 0;
For (I = 0; I <n; I ++) ws [wv [I] ++;
For (I = 1; I <m; I ++) ws [I] + = ws [I-1];
For (I = n-1; I> = 0; I --)
Sa [-- ws [wv [I] = y [I];
For (t = x, x = y, y = t, p = 1, x [sa [0] = 0, I = 1; I <n; I ++)
X [sa [I] = cmp (y, sa [I-1], sa [I], j )? P-1: p ++;
}
}
Void calheight (int * r, int * sa, int n)
{
Int I, j, k = 0;
For (I = 1; I <= n; I ++)
Rank [sa [I] = I;
For (I = 0; I <n; height [rank [I ++] = k)
For (k? K --: 0, j = sa [rank [I]-1]; r [I + k] = r [j + k]; k ++ );
}
Bool check (int mid, int len, int k)
{
Int I, j, tot = 0;
For (I = 2; I <= len; I ++)
{
If (height [I] <mid) tot = 0;
Else
{
Tot ++;
If (tot = k-1) return true;
}
}
Return false;
}
Int Binary (int st, int ed, int len, int k)
{
Int l = st, r = ed, mid;
While (l <r)
{
Mid = (l + r + 1)/2;
If (check (mid, len, k) l = mid;
Else r = mid-1;
}
Return l;
}
Int main ()
{
Int I, j, n, k, ans;
While (~ Scanf ("% d", & n, & k ))
{
For (I = 0; I <n; I ++)
{
Scanf ("% d", & r [I]);
R [I] ++;
}
R [n] = 0;
Da (r, sa, n + 1, 02 );
Calheight (r, sa, n );
Int ans = Binary (0, n, n, k );
Printf ("% d \ n", ans );
}
Return 0;
}
# Include <stdio. h>
# Include <string. h>
# Define N 1000010
Int wa [N], wb [N], wv [N], ws [N];
Int rank [N], height [N];
Int sa [N], r [N];
Int abs (int x)
{
Return x <0? -X: x;
}
Int cmp (int * r, int a, int B, int l)
{
Return r [a] = r [B] & r [a + l] = r [B + l];
}
Void da (int * r, int * sa, int n, int m)
{
Int I, j, p, * x = wa, * y = wb, * t;
For (I = 0; I <m; I ++) ws [I] = 0;
For (I = 0; I <n; I ++) ws [x [I] = r [I] ++;
For (I = 1; I <m; I ++) ws [I] + = ws [I-1];
For (I = n-1; I> = 0; I --) sa [-- ws [x [I] = I;
For (p = 1, j = 1; p <n; j * = 2, m = p)
{
For (p = 0, I = n-j; I <n; I ++) y [p ++] = I;
For (I = 0; I <n; I ++) if (sa [I]> = j) y [p ++] = sa [I]-j;
For (I = 0; I <n; I ++) wv [I] = x [y [I];
For (I = 0; I <m; I ++) ws [I] = 0;
For (I = 0; I <n; I ++) ws [wv [I] ++;
For (I = 1; I <m; I ++) ws [I] + = ws [I-1];
For (I = n-1; I> = 0; I --)
Sa [-- ws [wv [I] = y [I];
For (t = x, x = y, y = t, p = 1, x [sa [0] = 0, I = 1; I <n; I ++)
X [sa [I] = cmp (y, sa [I-1], sa [I], j )? P-1: p ++;
}
}
Void calheight (int * r, int * sa, int n)
{
Int I, j, k = 0;
For (I = 1; I <= n; I ++)
Rank [sa [I] = I;
For (I = 0; I <n; height [rank [I ++] = k)
For (k? K --: 0, j = sa [rank [I]-1]; r [I + k] = r [j + k]; k ++ );
}
Bool check (int mid, int len, int k)
{
Int I, j, tot = 0;
For (I = 2; I <= len; I ++)
{
If (height [I] <mid) tot = 0;
Else
{
Tot ++;
If (tot = k-1) return true;
}
}
Return false;
}
Int Binary (int st, int ed, int len, int k)
{
Int l = st, r = ed, mid;
While (l <r)
{
Mid = (l + r + 1)/2;
If (check (mid, len, k) l = mid;
Else r = mid-1;
}
Return l;
}
Int main ()
{
Int I, j, n, k, ans;
While (~ Scanf ("% d", & n, & k ))
{
For (I = 0; I <n; I ++)
{
Scanf ("% d", & r [I]);
R [I] ++;
}
R [n] = 0;
Da (r, sa, n + 1, 02 );
Calheight (r, sa, n );
Int ans = Binary (0, n, n, k );
Printf ("% d \ n", ans );
}
Return 0;
}