QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 256 MB Puntuación total: 100

#22673. Romeo Meets Juliet

Estadísticas

Farmer John has two feuding herds of cattle, the Moontagues and the Cowpulets. One of the bulls in the Moontague herd, Romeo, has fallen in love with Juliet, a Cowpulet. Romeo would like to meet with Juliet, but he doesn't want the other members of the Cowpulet herd to find out.

Romeo and Juliet want to meet and graze in as large a region as possible along the pasture fence. However, this region should not contain too many Cowpulets, otherwise the chance of the two being caught is too great. Romeo has determined where along the fence each of the $N$ ($1 \le N \le 1000$) members of the Cowpulet herd grazes. The long straight fence contains $P$ ($1 \le P \le 1000$) equally-spaced posts numbered $1..P$. Each Cowpulet grazes between some pair of adjacent posts. Help Romeo determine the length of the largest contiguous region along the fence containing no more than $C$ ($0 \le C \le 1000$) members of the Cowpulet herd.

Input

  • Line 1: Three separated integers: $N$, $P$, and $C$
  • Lines $2..N+1$: Each line contains an integer $X$, in the range $1..P-1$, specifying that a member of the Cowpulet herd grazes between fence posts $X$ and $X+1$. Multiple Cowpulets can graze between any given pair of fence posts.

Output

  • Line 1: A single integer specifying the size (the number of gaps between fence posts) of the largest contiguous region containing at most $C$ Cowpulets.

Examples

Input 1

2 6 1
2
3

Output 1

3

Input Details

There are six fence posts: 1, 2, 3, 4, 5, and 6. Of the two Cowpulets, one grazes between posts 2 & 3, and the other grazes between posts 3 & 4.

Output Details

Between fence posts 3 and 6 (an interval of size 3) there is only one Cowpulet.

PROBLEM 8: Romeo Meets Juliet [???, 26/0]

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.