Submission #1558513


Source Code Expand

#include <bits/stdc++.h>
#include <ostream>

#define getNum(i) scanf("%d", &(i))
#define MODULO 1000000007l
#define INF 100000000
#define FOR(i,j,k) for(int (i)=(j);(i)<=(k);(i)++)
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
typedef long long ll;

const int maxn = 1e5 + 10;

int main() {

#ifdef CONTEST
    freopen("input.in", "r", stdin);
#endif
    IOS
    int n;
    cin >> n;
    vector<int> a(n);
    FOR(i,0,n-1) cin >> a[i];
    sort(a.begin(), a.end());
    int cnt = 1;
    FOR(i,0,1e5+10) {
        vector<int>::iterator st = lower_bound(a.begin(), a.end(), i-1);
        vector<int>::iterator nd = prev(upper_bound(a.begin(), a.end(), i+1));
        if (nd > st) {
            cnt = max(cnt, static_cast<const int &>(nd - st + 1));
        }
    }
    cout << cnt << endl;

}

Submission Info

Submission Time
Task C - Together
User AshaD0w
Language C++14 (GCC 5.4.1)
Score 300
Code Size 872 Byte
Status AC
Exec Time 25 ms
Memory 640 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 2 ms 256 KB
0_001.txt AC 2 ms 256 KB
0_002.txt AC 1 ms 256 KB
1_003.txt AC 2 ms 256 KB
1_004.txt AC 14 ms 640 KB
1_005.txt AC 14 ms 640 KB
1_006.txt AC 14 ms 640 KB
1_007.txt AC 16 ms 640 KB
1_008.txt AC 25 ms 640 KB