#include #include #include int brandLast [1000001]; int standLastCnt [1000001]; int sortedBrandsBr[1000000]; /* by first occurence */ int sortedBrandsSt[1000000]; /* by first occurence */ int sortedBrandsCnt; int intervalBegin; int minIntervalBegin, minIntervalEnd; int minSamples; int standSamples [1000001]; /* prefix sums */ int main() { int N; /* stands */ int K; /* brands */ while (scanf("%d %d\n", &N, &K) == 2) { int i,s; for (i = 1; i<=K; i++) { brandLast[i] = 0; } sortedBrandsCnt = 0; intervalBegin = 1; minSamples = INT_MAX; standSamples[0] = 0; for (s = 1; s <= N; s++) { /* reading test case */ standLastCnt[s] = 0; int L; scanf("%d ", &L); standSamples[s] = L; standSamples[s] += standSamples[s-1]; for (i = 0; i= K) { while ((standLastCnt[intervalBegin] == 0) && (intervalBegin= K) { /* solution exists */ s=0; for (i=0; i