1

I've been stuck on this question for a while (https://code.google.com/codejam/contest/635101/dashboard#s=p2).

In the analysis of the question (https://code.google.com/codejam/contest/635101/dashboard#s=a&a=2) I understand that K is the rank of N in the set S and it will always be the largest and end number.

However, it says "Suppose there are K' numbers in S'". But since K is the rank of the number, wouldn't it be the same as K'?

It seems S' has a different amount of numbers than S? Is that right?

fragga
  • 13
  • 2

1 Answers1

1

S' is defined as the intersection of S with {1, 2, ..., K}. Now, even though it may seem as if S' itself is {1, 2, ..., K}, it may not be.

You are supposed to pick S as a subset of the set {2, 3, ..., N}. It doesn't have to consist of all the elements in the set {2, 3, ..., N}. When you take this into account, the intersection of S with {1, 2, ..., K} does not have to include all the elements {1, 2, ..., K}. Consequently, when the tutorial says "Suppose there are K' numbers in S'", K doesn't have to be K', as S' has a different amount of numbers than S.

It is kind of intuitive to notice that S' has different amount of elements than S considering their definition. S is a subset of {2, 3, ..., N} while S' is the intersection of S with {1, 2, ..., K}.

ilim
  • 4,164
  • 7
  • 22
  • 42