Submission #2252070
Source Code Expand
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
using namespace std;
const int INF = 10000000;
typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
//char maze[100][101];
ll n, m;
int sx, sy;
int gx, gy;
int qqq;
//各座標までの最短距離
int d[100][100];
//移動方向のベクトル
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int ans = 0;
pair<int, int> red[101], blue[101];
//ll a[200000], b[20000];
//ユークリッドの互除法
ll gcd(ll x, ll y) {
if (x < y) swap(x, y);
if (y == 0) return x;
return gcd(y, x%y);
}
//エラトステネスの篩 prime(n)[k]で1~nまで探索して(k+1)番目の素数を出力
vector<int> prime(int n) {
vector<int> erst;
for (int i = 0; i < n; ++i) erst.PB(i);
erst[0] = erst[1] = NULL;
auto dmax = sqrt(n);
for (int dx = 2; dx < dmax; ++dx) {
if (erst[dx] == NULL) continue;
for (int i = dx * 2; i < n; i += dx) erst[i] = NULL;
}
vector<int> erstlist;
for (auto i : erst) if (i) erstlist.PB(i);
return erstlist;
}
ll v_find(std::vector<ll> vec, ll number) {
auto itr = std::find(vec.begin(), vec.end(), number);
size_t index = std::distance(vec.begin(), itr);
if (index != vec.size()) { // 発見できたとき
return 1;
}
else { // 発見できなかったとき
return 0;
}
}
ll BIG = 10000000000;
ll POW(ll a, ll b) {
if (b == 0) return 1;
return (a*POW(a, b - 1)) % BIG;
}
int Kaijou(int a) {
if (a < 2) return 1;
return a * Kaijou(a - 1);
}
ll aa[51];
int main() {
int n;
cin >> n;
int a[100000] = { 0 };
int da[100000] = { 0 };
for (int i = 0; i < n; ++i) {
cin >> a[i];
da[a[i]]++;
if (a[i] != 0) da[a[i] - 1]++;
if (a[i] != 99999) da[a[i] + 1]++;
}
int maxid = -1,M=0;
for (int i = 0; i < 100000; ++i) {
if (M < da[i]) {
M = da[i];
maxid = i;
}
}
cout << M << endl;
return 0;
}
Submission Info
Submission Time
2018-03-24 21:46:24+0900
Task
C - Together
User
Black__Lotus
Language
C++14 (GCC 5.4.1)
Score
300
Code Size
2213 Byte
Status
AC
Exec Time
30 ms
Memory
1024 KB
Compile Error
./Main.cpp: In function ‘std::vector<int> prime(int)’:
./Main.cpp:72:20: warning: converting to non-pointer type ‘__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}’ from NULL [-Wconversion-null]
erst[0] = erst[1] = NULL;
^
./Main.cpp:76:19: warning: NULL used in arithmetic [-Wpointer-arith]
if (erst[dx] == NULL) continue;
^
./Main.cpp:77:48: warning: converting to non-pointer type ‘__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}’ from NULL [-Wconversion-null]
for (int i = dx * 2; i < n; i += dx) erst[i] = NULL;
^
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
2 ms
1024 KB
0_001.txt
AC
2 ms
1024 KB
0_002.txt
AC
2 ms
1024 KB
1_003.txt
AC
2 ms
1024 KB
1_004.txt
AC
17 ms
1024 KB
1_005.txt
AC
30 ms
1024 KB
1_006.txt
AC
30 ms
1024 KB
1_007.txt
AC
30 ms
1024 KB
1_008.txt
AC
29 ms
1024 KB