結果
問題 |
No.9 モンスターのレベル上げ
|
ユーザー |
![]() |
提出日時 | 2024-12-13 02:24:31 |
言語 | C90 (gcc 12.3.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,362 bytes |
コンパイル時間 | 352 ms |
コンパイル使用メモリ | 27,264 KB |
最終ジャッジ日時 | 2025-03-25 02:58:04 |
合計ジャッジ時間 | 869 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.c: In function 'sort_aux': main.c:18:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode 18 | for(int i=0;i<256;++i){ | ^~~ main.c:18:9: note: use option '-std=c99', '-std=gnu99', '-std=c11' or '-std=gnu11' to compile your code main.c:21:17: error: redefinition of 'i' 21 | for(int i=0;i<n;++i){ | ^ main.c:18:17: note: previous definition of 'i' with type 'int' 18 | for(int i=0;i<256;++i){ | ^ main.c:21:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode 21 | for(int i=0;i<n;++i){ | ^~~ main.c:25:17: error: redefinition of 'i' 25 | for(int i=0;i<256;++i){ | ^ main.c:21:17: note: previous definition of 'i' with type 'int' 21 | for(int i=0;i<n;++i){ | ^ main.c:25:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode 25 | for(int i=0;i<256;++i){ | ^~~ main.c:30:17: error: redefinition of 'i' 30 | for(int i=0;i<n;++i){ | ^ main.c:25:17: note: previous definition of 'i' with type 'int' 25 | for(int i=0;i<256;++i){ | ^ main.c:30:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode 30 | for(int i=0;i<n;++i){ | ^~~ main.c: In function 'main': main.c:39:21: error: expected ';' before 'i' 39 | rep(i,n){ | ^ main.c:8:31: note: in definition of macro 'rep' 8 | #define rep(v,e) for(typeof(e)v=0;v<e;++v) | ^ main.c:39:21: error: 'i' undeclared (first use in this function) 39 | rep(i,n){ | ^ main.c:8:35: note: in definition of macro 'rep' 8 | #define rep(v,e) for(typeof(e)v=0;v<e;++v) | ^ main.c:39:21: note: each u
ソースコード
#pragma GCC optimize("Ofast") #pragma GCC target("avx2") #define rd_init() char*rp=({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);}) #define rd() ({int _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;}) #define wt(v) ({unsigned _z=v;do*--wp=_z%10+48;while(_z/=10);}) #define wt1(v) ({char wbuf[64],*wp=wbuf+sizeof wbuf;wt(v);write(1,wp,wbuf+sizeof wbuf-wp);}) #define rep(v,e) for(typeof(e)v=0;v<e;++v) #define chmax(v,a) (v=v>=(a)?v:(a)) int n; unsigned a[1500]; unsigned q[1501]; unsigned b[1500]; void sort_aux(unsigned*a,unsigned*b){ int c[256]; for(int i=0;i<256;++i){ c[i]=0; } for(int i=0;i<n;++i){ ++c[a[i]&255]; } int t=0; for(int i=0;i<256;++i){ int u=c[i]; c[i]=t; t+=u; } for(int i=0;i<n;++i){ b[c[a[i]&255]++]=a[i]>>8|a[i]<<24; } } int main(){ { rd_init(); n=rd(); rep(i,n){ a[i]=rd()<<16; } rep(i,n){ b[i]=rd()>>1<<16|1; } } sort_aux(a,q); sort_aux(q,a); sort_aux(a,q); sort_aux(q,a); q[n]=~0; int z=n; rep(h,n){ rep(i,n){ q[i]=a[i]; } int w=0; rep(i,n){ int j=h+i; j-=j>=n?n:0; q[0]+=b[j]; unsigned y=q[0]&0xffff; if(y>=z){ goto hoge; } chmax(w,y); int k=0; while(k*2<n-1){ int c=q[k*2+1]<q[k*2+2]?k*2+1:k*2+2; if(q[k]<=q[c]){ break; } unsigned t=q[c]; q[c]=q[k]; q[k]=t; k=c; } } z=w; hoge:; } wt1(z); _exit(0); }