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. E20171230-hm

    refine   vt. 提炼; 改善; 使高雅; revert  vi. 恢复; 重提; 回到…上; <律>归还;             vt. 使恢复原状;            n ...

  2. bzoj 2878: [Noi2012]迷失游乐园【树上期望dp+基环树】

    参考:https://blog.csdn.net/shiyukun1998/article/details/44684947 先看对于树的情况 设d[u]为点u向儿子走的期望长度和,du[u]为u点的 ...

  3. react hooks 全面转换攻略(一) react本篇之useState,useEffect

    useState 经典案例: import { useState } from 'react'; function Example() { const [count, setCount] = useS ...

  4. liunx 用户切换 su sudo

    liunx 用户操作#useradd test#passwd test 用户身份切换su 切换用户 需要知道切换用户的密码1.su [-lm] [-c命令] [username] #su -login ...

  5. nodejs安装node-rsa遇到的问题及解决

    nodejs第一次使用,故碰到一些小白问题: 1.使用 npm install node-rsa -S 2.封装rsa import NodeRSA from 'node-rsa'; const rs ...

  6. (三)Mybatis总结之动态sql

    动态sql 为何需要动态sql?因为简单的sql语句已经不能满足复杂的业务需求 动态sql相当于sql语句拼接 1.if语句 if语句:判断,如果执行多条件查询,如果中间某个条件变量为空,就跳过当前判 ...

  7. git初使用的心得

    转到Java方向后,版本控制工具也开始以git为主了.由于之前不怎么使用bash,所以目前还是以ui工具,比如sourcetree为主导,但一些简单的操作命令,已经能够快速地使用.sourcetree ...

  8. [ CodeForces 1064 B ] Equations of Mathematical Magic

    \(\\\) \(Description\) \(T\) 组询问,每次给出一个 \(a\),求方程 \[ a-(a\oplus x)-x=0 \] 的方案数. \(T\le 10^3,a\le 2^{ ...

  9. Jmeter接口测试---get和post及解决乱码问题

    Jmeter接口测试---get请求 1.创建一个线程组 测试计划---添加---Threads ---线程组 2.添加http请求,步骤如下图所示: 3.添加带有参数的get请求,如下图展示内容: ...

  10. Python+selenium测试环境成功搭建,简单控制浏览器(firefox)接下来,继续学习其他浏览器上的测试环境搭建;学习Python语言,利用Python语言来写测试用例。加油!!!

    Python+selenium测试环境成功搭建,简单控制浏览器(firefox)接下来,继续学习其他浏览器上的测试环境搭建:学习Python语言,利用Python语言来写测试用例.加油!!!