結果

問題 No.3009 異なる数字の最大の範囲(勉強会用)
ユーザー iiljjiiljj
提出日時 2021-01-15 02:35:47
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 7 ms / 5,000 ms
コード長 827 bytes
コンパイル時間 388 ms
コンパイル使用メモリ 31,488 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-30 17:45:16
合計ジャッジ時間 968 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,820 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 1 ms
6,948 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 6 ms
6,944 KB
testcase_16 AC 6 ms
6,940 KB
testcase_17 AC 6 ms
6,940 KB
testcase_18 AC 7 ms
6,940 KB
testcase_19 AC 6 ms
6,944 KB
testcase_20 AC 6 ms
6,944 KB
testcase_21 AC 6 ms
6,944 KB
testcase_22 AC 6 ms
6,940 KB
testcase_23 AC 5 ms
6,940 KB
testcase_24 AC 3 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'main':
main.c:10:81: warning: implicit declaration of function 'putc_unlocked' [-Wimplicit-function-declaration]
   10 | #define wt_int(var, buf, ptr) while(var){buf[ptr++]=var%10;var/=10;}while(ptr--)putc_unlocked(buf[ptr]+'0',stdout);
      |                                                                                 ^~~~~~~~~~~~~
main.c:35:5: note: in expansion of macro 'wt_int'
   35 |     wt_int(ma, buf, n);
      |     ^~~~~~

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
// stdout
#include <stdio.h>
// mmap
#include <sys/mman.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 = 0;
    int ma = 0;
    for (int right = 0; right < n; ++right) {
        ++cnt[a[right]];
        while (cnt[a[right]] > 1) cnt[a[left++]]--;
        if (right - left + 1 > ma) ma = right - left + 1;
    }

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