Points: 3 (partial)
Time limit: 5.0s
Memory limit: 64M
Given a list of () positive integers less than or equal to , print out how many distinct numbers exist.
The first line will contain the integer . The next lines will contain an element in the list.
One integer: the number of distinct elements in the given list.
Sample Input 1
2 1 2
Sample Output 1
Sample Input 2
4 1 2 2 5
Sample Output 2
this is so sad
You one-liners make me feel bad...
Hint: sets have very fast O(1)
inchecks, whereas lists have very slow O(n)
inchecks. Your solution will probably pass if you use a set, but you may have to combine your two for loops into one.
It appears that your solution doesn't have the intended complexity (the real testdata used to have N <= 20). As such, the limits have been increased and solutions have been rejudged :)