結果
| 問題 |
No.8009 異なる数字の最大の範囲(勉強会用)
|
| ユーザー |
iiljj
|
| 提出日時 | 2021-01-15 02:35:47 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 5,000 ms |
| コード長 | 827 bytes |
| コンパイル時間 | 200 ms |
| コンパイル使用メモリ | 31,360 KB |
| 実行使用メモリ | 6,528 KB |
| 最終ジャッジ日時 | 2024-11-20 15:02:38 |
| 合計ジャッジ時間 | 1,088 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
コンパイルメッセージ
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);
| ^~~~~~
ソースコード
#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;
}
iiljj