Submission #1558511


Source Code Expand

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
using namespace std;

#define ll long long
#define forn(i,n)for(i=0;i<n;i++)
#define forc(i,c,n)for(i=c;i<=n;i++)
typedef list<ll> LST;
typedef vector<ll> VEC;
typedef map<ll, ll> MAP;


int main() {
	ifstream fin("Text.txt");
	int i, j, k;
	ll a, b,t, c, e, n,x,y, m, r, d, q,ans=0;
	cin >> n;
	VEC vc(n);
	forn(i, n) {
		cin >> vc[i];
	}
	sort(vc.begin(), vc.end());
	i = 0;
	j = 0;
	while (j<n && i <n)
	{
		if (vc[j] - vc[i] <= 2) {
			ans = max(ans, (ll)(j - i + 1));
			j++;
		}
		else {
			i++;
		}
	}
	cout << ans << endl;
	return 0;
}

Submission Info

Submission Time
Task C - Together
User freestyler
Language C++14 (GCC 5.4.1)
Score 300
Code Size 811 Byte
Status AC
Exec Time 36 ms
Memory 1024 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 9
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt
Case Name Status Exec Time Memory
0_000.txt AC 1 ms 256 KB
0_001.txt AC 1 ms 256 KB
0_002.txt AC 1 ms 256 KB
1_003.txt AC 1 ms 256 KB
1_004.txt AC 18 ms 1024 KB
1_005.txt AC 31 ms 1024 KB
1_006.txt AC 31 ms 1024 KB
1_007.txt AC 33 ms 1024 KB
1_008.txt AC 36 ms 1024 KB