結果
問題 | No.1630 Sorting Integers (Greater than K) |
ユーザー | tails |
提出日時 | 2021-07-31 07:59:46 |
言語 | C (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,106 bytes |
コンパイル時間 | 396 ms |
コンパイル使用メモリ | 32,896 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-16 09:07:55 |
合計ジャッジ時間 | 1,521 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 1 ms
5,376 KB |
testcase_07 | AC | 1 ms
5,376 KB |
testcase_08 | AC | 1 ms
5,376 KB |
testcase_09 | AC | 1 ms
5,376 KB |
testcase_10 | AC | 1 ms
5,376 KB |
testcase_11 | AC | 1 ms
5,376 KB |
testcase_12 | AC | 1 ms
5,376 KB |
testcase_13 | AC | 1 ms
5,376 KB |
testcase_14 | AC | 1 ms
5,376 KB |
testcase_15 | AC | 1 ms
5,376 KB |
testcase_16 | AC | 4 ms
5,376 KB |
testcase_17 | AC | 4 ms
5,376 KB |
testcase_18 | AC | 3 ms
5,376 KB |
testcase_19 | AC | 3 ms
5,376 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 2 ms
5,376 KB |
testcase_23 | AC | 1 ms
5,376 KB |
testcase_24 | AC | 3 ms
5,376 KB |
testcase_25 | AC | 3 ms
5,376 KB |
testcase_26 | AC | 3 ms
5,376 KB |
コンパイルメッセージ
main.c:12:1: warning: return type defaults to 'int' [-Wimplicit-int] 12 | main(){ | ^~~~ main.c: In function 'main': main.c:17:19: warning: initialization of 'char *' from 'long int' makes pointer from integer without a cast [-Wint-conversion] 17 | char*klen=rp-kp-1; | ^~ main.c:23:16: warning: comparison between pointer and integer 23 | if(klen>n){ | ^ main.c:24:17: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration] 24 | write(1,"-1",2); | ^~~~~ main.c:25:17: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration] 25 | _exit(0); | ^~~~~ | _Exit main.c:27:16: warning: comparison between pointer and integer 27 | if(klen<n){ | ^ main.c:30:25: warning: implicit declaration of function 'memset' [-Wimplicit-function-declaration] 30 | memset(wp,i+'1',c[i]); | ^~~~~~ main.c:1:1: note: include '<string.h>' or provide a declaration of 'memset' +++ |+#include <string.h> 1 | #pragma GCC optimize("Ofast") main.c:30:25: warning: incompatible implicit declaration of built-in function 'memset' [-Wbuiltin-declaration-mismatch] 30 | memset(wp,i+'1',c[i]); | ^~~~~~ main.c:30:25: note: include '<string.h>' or provide a declaration of 'memset' main.c:71:25: warning: incompatible implicit declaration of built-in function 'memset' [-Wbuiltin-declaration-mismatch] 71 | memset(wp,i+'1',c[i]); | ^~~~~~ main.c:71:25: note: include '<string.h>' or provide a declaration of 'memset'
ソースコード
#pragma GCC optimize("Ofast") #pragma GCC target("avx2") char*mmap(); char wbuf[1<<25]; #define rd_skip() while(*rp++>=48) #define rd(v) long v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;} #define rep(v,e) for(long v=0;v<e;++v) #define chmax(v,a) (v=v>=a?v:a) main(){ char*rp=mmap(0l,1l<<25,1,2,0,0ll); rd(n); char*kp=rp; rd_skip(); char*klen=rp-kp-1; long c[9]; rep(i,9){ rd(ci); c[i]=ci; } if(klen>n){ write(1,"-1",2); _exit(0); } if(klen<n){ char*wp=wbuf; rep(i,9){ memset(wp,i+'1',c[i]); wp+=c[i]; } write(1,wbuf,wp-wbuf); _exit(0); } { char*wp=wbuf; long d=0; while(d<n&&c[kp[d]-'1']){ --c[kp[d]-'1']; *wp++=kp[d++]; } long imax=0; rep(i,9){ if(c[i]){ imax=i; } } if(d==n){ --d; ++c[*--wp-'1']; } while(d>=0&&imax<=kp[d]-'1'){ chmax(imax,kp[d]-'1'); --d; ++c[*--wp-'1']; } if(d<0){ write(1,"-1",2); _exit(0); } { long i=kp[d]+1-'1'; while(!c[i]){ ++i; } *wp++=i+'1'; --c[i]; } rep(i,9){ memset(wp,i+'1',c[i]); wp+=c[i]; } write(1,wbuf,wp-wbuf); _exit(0); } }