CF386B.Fly, freebies, fly!
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Everyone loves a freebie. Especially students.
It is well-known that if in the night before exam a student opens window, opens the student's record-book and shouts loudly three times "Fly, freebie, fly!" — then flown freebie helps him to pass the upcoming exam.
In the night before the exam on mathematical analysis n students living in dormitory shouted treasured words. The i-th student made a sacrament at the time t__i, where t__i is the number of seconds elapsed since the beginning of the night.
It is known that the freebie is a capricious and willful lady. That night the freebie was near dormitory only for T seconds. Therefore, if for two students their sacrament times differ for more than T, then the freebie didn't visit at least one of them.
Since all students are optimists, they really want to know what is the maximal number of students visited by the freebie can be.
每个人都喜欢免费赠品,尤其是学生们。
众所周知,如果在考试前夜,一名学生打开窗户,翻开自己的学生证,并大声喊三遍:“飞吧,赠品,快飞吧!”——那么飞来的赠品便会助他通过即将来临的考试。
在数学分析考试前夜,宿舍里共有 n 名学生喊出了这句珍贵的咒语。第 i 名学生在时刻 ti 进行了这一仪式,其中 ti 表示从午夜开始经过的秒数。
众所周知,赠品是一位反复无常、任性而为的女士。那一晚,赠品仅在宿舍附近停留了 T 秒。因此,若两名学生的仪式时刻之差超过 T,则赠品至少未能拜访其中一人。
由于所有学生都是乐观主义者,他们迫切希望知道:赠品最多可能拜访多少名学生?
输入格式
The first line of the input contains integer n (1 ≤ n ≤ 100), where n — the number of students shouted "Fly, freebie, fly!" The second line contains n positive integers t__i (1 ≤ t__i ≤ 1000).
The last line contains integer T (1 ≤ T ≤ 1000) — the time interval during which the freebie was near the dormitory.
输入的第一行包含一个整数 n(1 ≤ n ≤ 100),其中 n 表示喊出“飞吧,免费赠品,飞吧!”的学生人数。
第二行包含 n 个正整数 ti(1 ≤ ti ≤ 1000)。
最后一行包含一个整数 T(1 ≤ T ≤ 1000)——表示免费赠品停留在宿舍附近的持续时间。
输出格式
Print a single integer — the largest number of people who will pass exam tomorrow because of the freebie visit.
输出一个整数——因免费访问而明天通过考试的人数的最大值。
输入输出样例
输入#1
6 4 1 7 8 3 8 1
输出#1
3
输入解题思路,AI测评打分。不知道怎么写?