Submission #1551977


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int n, m;
int a[100000 + 5];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    rep(i, m) cin >> a[i];
    int ans = 0;
    rep(i, m) {
        int cnt = upper_bound(a, a + m, a[i] + n) - a;
        cnt -= i;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

Submission Info

Submission Time
Task H - アクセス頻度
User roto_37
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1401 Byte
Status AC
Exec Time 16 ms
Memory 640 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 43
Set Name Test Cases
All 00-sample00, 00-sample01, edge-00, edge-01, largest-00, largest-01, largest-02, largest-03, largest-04, largest-05, random-00, random-01, random-02, random-03, random-04, random-05, random-06, random-07, random-08, random-09, random-10, random-11, random-12, random-13, random-14, random-15, random-16, random-17, random-18, random-19, random-20, random-21, random-22, random-23, random-24, random-25, random-26, random-27, random-28, random-29, sample-00, sample-01, smallest-00
Case Name Status Exec Time Memory
00-sample00 AC 1 ms 256 KB
00-sample01 AC 1 ms 256 KB
edge-00 AC 10 ms 640 KB
edge-01 AC 1 ms 256 KB
largest-00 AC 14 ms 640 KB
largest-01 AC 15 ms 640 KB
largest-02 AC 16 ms 640 KB
largest-03 AC 14 ms 640 KB
largest-04 AC 15 ms 640 KB
largest-05 AC 14 ms 640 KB
random-00 AC 6 ms 384 KB
random-01 AC 9 ms 512 KB
random-02 AC 10 ms 512 KB
random-03 AC 7 ms 384 KB
random-04 AC 7 ms 512 KB
random-05 AC 4 ms 384 KB
random-06 AC 14 ms 640 KB
random-07 AC 14 ms 640 KB
random-08 AC 10 ms 512 KB
random-09 AC 11 ms 640 KB
random-10 AC 10 ms 512 KB
random-11 AC 14 ms 640 KB
random-12 AC 11 ms 512 KB
random-13 AC 4 ms 384 KB
random-14 AC 13 ms 640 KB
random-15 AC 8 ms 512 KB
random-16 AC 6 ms 384 KB
random-17 AC 11 ms 512 KB
random-18 AC 8 ms 512 KB
random-19 AC 3 ms 384 KB
random-20 AC 6 ms 384 KB
random-21 AC 6 ms 384 KB
random-22 AC 5 ms 384 KB
random-23 AC 9 ms 512 KB
random-24 AC 13 ms 640 KB
random-25 AC 2 ms 256 KB
random-26 AC 12 ms 640 KB
random-27 AC 2 ms 256 KB
random-28 AC 3 ms 256 KB
random-29 AC 3 ms 384 KB
sample-00 AC 1 ms 256 KB
sample-01 AC 1 ms 256 KB
smallest-00 AC 1 ms 256 KB