結果

問題 No.4 おもりと天秤
ユーザー testestesttestestest
提出日時 2015-08-10 03:12:17
言語 C90
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 384 bytes
コンパイル時間 116 ms
コンパイル使用メモリ 24,852 KB
実行使用メモリ 6,112 KB
最終ジャッジ日時 2023-09-25 07:49:25
合計ジャッジ時間 7,018 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 0 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 0 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 0 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 0 ms
4,380 KB
testcase_15 AC 0 ms
4,376 KB
testcase_16 AC 0 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:16:1: warning: implicit declaration of function ‘scanf’ [-Wimplicit-function-declaration]
 scanf("%d",&n);
 ^~~~~
main.c:16:1: warning: incompatible implicit declaration of built-in function ‘scanf’
main.c:16:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
main.c:1:1:
+#include <stdio.h>
 int a[100],n;
main.c:16:1:
 scanf("%d",&n);
 ^~~~~
main.c:18:9: warning: implicit declaration of function ‘puts’ [-Wimplicit-function-declaration]
 if(s%2){puts("impossible");return 0;}
         ^~~~
main.c:19:1: warning: implicit declaration of function ‘qsort’ [-Wimplicit-function-declaration]
 qsort(a,n,4,c);
 ^~~~~

ソースコード

diff #

int a[100],n;

int c(const void*a,const void*b){return*(int*)a-*(int*)b;}

int v(int x,int i){
int j;
for(j=i+1;j<n&&a[j]<=x;j++){
if(a[j]==x)return 1;
if(a[j]<x)if(v(x-a[j],j))return 1;
}
return 0;
}

int main(){
int i,s=0;
scanf("%d",&n);
for(i=0;~scanf("%d",a+i);)s+=a[i++];
if(s%2){puts("impossible");return 0;}
qsort(a,n,4,c);
puts(v(s/2,-1)?"possible":"impossible");
return 0;
}
0