結果

問題 No.8009 異なる数字の最大の範囲(勉強会用)
ユーザー iiljj
提出日時 2021-01-15 02:38:22
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 865 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 287 ms
コンパイル使用メモリ 42,748 KB
最終ジャッジ日時 2026-02-22 06:38:59
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
// stdout
#include <stdio.h>
// mmap
#include <sys/mman.h>
// exit
#include <stdlib.h>

// clang-format off
#define RD(v) int v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;}
#define wt_int(var, buf, ptr) while(var){buf[ptr++]=var%10;var/=10;}while(ptr--)putc_unlocked(buf[ptr]+'0',stdout);
// clang-format on

int cnt[1000001];
int a[100000];

int main() {
    char *rp = mmap(0l, 1l << 28, 1, 2, 0, 0ll);
    RD(n);
    int *ap = a;
    for (int i = 0; i < n; ++i) {
        RD(t);
        *ap++ = t;
    }

    int *left = a;
    int ma = 0;
    for (int *right = a; right < ap; ++right) {
        ++cnt[*right];
        while (cnt[*right] > 1) cnt[*left++]--;
        if (right - left + 1 > ma) ma = right - left + 1;
    }

    char buf[7];
    n = 0;
    wt_int(ma, buf, n);
    exit(0);
    return 0;
}
0