http://codeforces.com/contest/1133/problem/C
time limit per test 2 seconds
memory limit per test 256 megabytes
inputstandard input
outputstandard output

You are a coach at your local university. There are $n$ students under your supervision, the programming skill of the i-th student is $a_i$.

You have to create a team for a new programming competition. As you know, the more students some team has the more probable its victory is! So you have to create a team with the maximum number of students. But you also know that a team should be balanced. It means that the programming skill of each pair of students in a created team should differ by no more than 5.

Your task is to report the maximum possible number of students in a balanced team.

Input

The first line of the input contains one integer $n$($1≤n≤2⋅10^5$) — the number of students.

The second line of the input contains $n$ integers $a_1,a_2,…,a_n$($1≤a_i≤10^9$), where $a_i$ is a programming skill of the i-th student.

Output

Print one integer — the maximum possible number of students in a balanced team.

Examples

input

6
1 10 17 12 15 2

output

3

input

10
1337 1337 1337 1337 1337 1337 1337 1337 1337 1337

output

10

input

6
1 1000 10000 10 100 1000000000

output

1

Note

In the first example you can create a team with skills [12,17,15].

In the second example you can take all students in a team because their programming skills are equal.

In the third example you can create a team consisting of a single student (and you cannot create a team consisting of at least two students).

解题思路

  官方:Let's sort all values in non-decreasing order. Then we can use two pointers to calculate for each student

Codeforces Round #544 (Div. 3) Editorial C. Balanced Team的更多相关文章

  1. Codeforces Round #544 (Div. 3) E. K Balanced Teams (DP)

    题意:有\(n\)个人,每个人的能力值是\(a_i\),现在你想将这些人分成\(k\)组(没必要全选),但是每组中最高水平和最低水平的人的能力差值必须\(\le 5\),问最多能选多少人. 题解:想了 ...

  2. Codeforces Round #544 (Div. 3) 题解

    Codeforces Round #544 (Div. 3) D. Zero Quantity Maximization 题目链接:https://codeforces.com/contest/113 ...

  3. Codeforces Round #590 (Div. 3) Editorial

    Codeforces Round #590 (Div. 3) Editorial 题目链接 官方题解 不要因为走得太远,就忘记为什么出发! Problem A 题目大意:商店有n件商品,每件商品有不同 ...

  4. Codeforces Round #747 (Div. 2) Editorial

    Codeforces Round #747 (Div. 2) A. Consecutive Sum Riddle 思路分析: 一开始想起了那个公式\(l + (l + 1) + - + (r − 1) ...

  5. CodeForces Round #544 Div.3

    A. Middle of the Contest 代码: #include <bits/stdc++.h> using namespace std; int h1, m1, h2, m2; ...

  6. Codeforces Round #544 (Div. 3)解题报告

    A.Middle of the Contest 考虑把输入的时间单位化成分钟,相加除以2就好了 #include<bits/stdc++.h> using namespace std; # ...

  7. Codeforces Round #544 (Div. 3) C. Balanced Team

    链接:https://codeforces.com/contest/1133/problem/C 题意: 给n个数, 在这n个数中选最多n个数,来组成一个队伍. 保证这n个数的最大最小差值不大于5. ...

  8. Codeforces Round #544 (Div. 3) dp + 双指针

    https://codeforces.com/contest/1133/problem/E 题意 给你n个数(n<=5000),你需要对其挑选并进行分组,总组数不能超过k(k<=5000) ...

  9. Codeforces Round #544 (Div. 3) D. Zero Quantity Maximization

    链接:https://codeforces.com/contest/1133/problem/D 题意: 给两个数组a,b. 同时ci = ai * d + bi. 找到一个d使c数组中的0最多. 求 ...

随机推荐

  1. Objective-C 对象的类型与动态结合

    创建: 2018/01/21 更新: 2018/01/22 标题前增加 [Objective-C] 完成: 2018/01/24 更新: 2018/01/24 加红加粗属性方法的声明 [不直接获取内部 ...

  2. 1617: [Usaco2008 Mar]River Crossing渡河问题(dp)

    1617: [Usaco2008 Mar]River Crossing渡河问题 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 1219  Solved:  ...

  3. [App Store Connect帮助]三、管理 App 和版本(8)编辑 App 的用户访问权限

    对于具有“App 管理”.“客户支持”.“开发者”.“营销”或“销售”职能的特定人员(均不具有“访问报告”职能),您可以限制其在 App Store Connect 帐户中对 App 的访问权限. 必 ...

  4. 流程图软件draw.io

    工作中经常需要梳理一些流程图,时序图.以前用微软Visio绘制流程图(当然不是正版Visio).后来为了响应国家号召,改用processon(proceson.com)进行绘制流程图.Processo ...

  5. 303 Range Sum Query - Immutable 区域和检索 - 不可变

    给定一个数组,求出数组从索引 i 到 j  (i ≤ j) 范围内元素的总和,包含 i,  j 两点.例如:给定nums = [-2, 0, 3, -5, 2, -1],求和函数为sumRange() ...

  6. 6.12---Swagger中paramType---swagger的RequestParam和ApiImpliciParam----Example中方法带有selective

    paramType:表示参数放在哪个地方    header-->请求参数的获取:@RequestHeader(代码中接收注解)    query-->请求参数的获取:@RequestPa ...

  7. opencv总结

    2018-02-2623:59:02 唉,这软件我很烦躁,今天又搞了好几遍,出错提示的时候总是出问题! 而且,无论什么错误,都是提示一堆乱码! 定义ROI区域有两种方法,第一种是使用cv:Rect.顾 ...

  8. 通过重写.htaccess文件添加404

    如果说是用linux服务器的系统 想要给自己的网站设置404怎么弄?如果你不会给自己的Ecs服务器添加服务器管理系统,或是你购买的云虚拟主机没有304.404设置,那么就要通过自己重写文件来设置404 ...

  9. servU服务器连接不上问题的解决

    在服务器上安装了servU64位版,建立了用户,设置了防火墙,正常启动. 但在客户端发出FTP://服务器IP 命令后,弹出输入用户名和密码的对话框,输入正确的用户名和密码后,却始终连接不上. ftp ...

  10. 对Oracle 、SQL Server、MySQL、PostgreSQL数据库优缺点分析

    对Oracle .SQL Server.MySQL.PostgreSQL数据库优缺点分析 Oracle Database Oracle Database,又名Oracle RDBMS,或简称Oracl ...