Tours
InterviewTime limit2sMemory limit1024 MB
Given n daily city visits, find the start day of the k-day window that contains the most distinct cities.
- Level
Easy3 of 10
- Topics
- Sliding window, Hash map, Array
- Solved
- No attempts yet
Problem
Anton will go on vacation soon. He will spend consecutive days on vacation. By the terms of his job, these must be some of the nearest days.
Anton plans to spend his vacation on guided tours. The tour office runs exactly one tour each day. On day , the tour goes to city . Cities on the planet are positive integers not exceeding . The office may run tours to the same city several times.
Anton likes to visit new places. Choose the vacation days so that he can visit the largest possible number of distinct cities during the vacation.
Input
The first line contains two integers and (), where is the number of days from which the vacation can be chosen and is the vacation length. The second line contains integers (), the cities of the tours on each day. Days are numbered from 1.
Output
Print one integer (), the number of the first day of the best vacation. If several answers exist, print any of them.