Submission #1793948
Source Code Expand
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>
using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)
typedef pair<int,int>P;
#define INF 1000000000
struct edge {
int from, to;
edge (int from, int to){
this->from=from; this->to=to;
}
};
int V,E;
typedef vector<edge> edges;
vector<edges> G;
int h[100005];
int main(){
int n, a;
scanf("%d ", &n);
FORI(0, n) {
scanf("%d ", &a);
h[a]++;
}
int ans = -1;
for(int i=0;i<100000;i++) {
int x = h[i];
if (i - 1 >= 0)
x += h[i - 1];
if (i + 1 < n)
x += h[i + 1];
ans = max(ans, x);
}
printf("%d\n", ans);
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Together |
User |
cypher512 |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
1277 Byte |
Status |
AC |
Exec Time |
12 ms |
Memory |
640 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:48:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d ", &n);
^
./Main.cpp:50:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d ", &a);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
300 / 300 |
Status |
|
|
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 |
9 ms |
256 KB |
1_005.txt |
AC |
11 ms |
256 KB |
1_006.txt |
AC |
11 ms |
256 KB |
1_007.txt |
AC |
11 ms |
256 KB |
1_008.txt |
AC |
12 ms |
640 KB |