結果
問題 | No.626 Randomized 01 Knapsack |
ユーザー | tails |
提出日時 | 2017-12-18 19:34:58 |
言語 | C (gcc 12.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 804 bytes |
コンパイル時間 | 321 ms |
コンパイル使用メモリ | 30,208 KB |
実行使用メモリ | 15,944 KB |
最終ジャッジ日時 | 2024-12-16 00:27:01 |
合計ジャッジ時間 | 55,590 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | RE | - |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | TLE | - |
testcase_07 | TLE | - |
testcase_08 | TLE | - |
testcase_09 | TLE | - |
testcase_10 | TLE | - |
testcase_11 | TLE | - |
testcase_12 | TLE | - |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | TLE | - |
testcase_20 | TLE | - |
testcase_21 | TLE | - |
testcase_22 | TLE | - |
testcase_23 | TLE | - |
testcase_24 | RE | - |
コンパイルメッセージ
main.c: In function 'ha': main.c:14:17: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 14 | printf("%lld\n",b); | ^~~~~~ main.c:2:1: note: include '<stdio.h>' or provide a declaration of 'printf' 1 | #include <signal.h> +++ |+#include <stdio.h> 2 | main.c:14:17: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] 14 | printf("%lld\n",b); | ^~~~~~ main.c:14:17: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:15:17: warning: implicit declaration of function 'exit' [-Wimplicit-function-declaration] 15 | exit(0); | ^~~~ main.c:2:1: note: include '<stdlib.h>' or provide a declaration of 'exit' 1 | #include <signal.h> +++ |+#include <stdlib.h> 2 | main.c:15:17: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch] 15 | exit(0); | ^~~~ main.c:15:17: note: include '<stdlib.h>' or provide a declaration of 'exit' main.c: At top level: main.c:47:1: warning: return type defaults to 'int' [-Wimplicit-int] 47 | main(i){ | ^~~~ main.c: In function 'main': main.c:47:1: warning: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:49:9: warning: implicit declaration of function 'ualarm' [-Wimplicit-function-declaration] 49 | ualarm(1000000,900000); | ^~~~~~ main.c:51:9: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 51 | scanf("%d%lld",&n,&c); | ^~~~~ main.c:51:9: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:51:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] main.c:51:9: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:55:9: warning: implicit
ソースコード
#include <signal.h> typedef long long ll; typedef struct{ll v,w,t,u;}S; int n; ll c; ll b; S ss[6000]; void ha(){ static int c=0; if(++c==2){ printf("%lld\n",b); exit(0); } } int sgn(double a){ return a<0?-1:a>0; } int cmp(void*a,void*b){ S*p=a,*q=b; return sgn((double)q->v/q->w-(double)p->v/p->w); } void dfs(int i,ll v,ll c){ if(i==n){ if(b<v){ b=v; } }else{ if(v+ss[i].t<=b){ return; } if(c>=ss[i].w){ dfs(i+1,v+ss[i].v,c-ss[i].w); } if(c<ss[i].u){ dfs(i+1,v,c); } } } main(i){ signal(14,ha); ualarm(1000000,900000); scanf("%d%lld",&n,&c); for(i=0;i<n;++i){ scanf("%lld%lld",&ss[i].v,&ss[i].w); } qsort(ss,n,sizeof(S),cmp); ll t=0,u=0; for(i=n;i--;){ ss[i].t=t+=ss[i].v; ss[i].u=u+=ss[i].w; } dfs(0,0ll,c); raise(14); raise(14); }