結果
問題 |
No.4 おもりと天秤
|
ユーザー |
|
提出日時 | 2016-12-26 13:32:28 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 403 bytes |
コンパイル時間 | 515 ms |
コンパイル使用メモリ | 20,736 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-14 23:44:03 |
合計ジャッジ時間 | 1,080 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 WA * 10 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:9:9: warning: implicit declaration of function ‘qsort’ [-Wimplicit-function-declaration] 9 | qsort(w,n,sizeof(int),cmp); | ^~~~~ main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | scanf("%d",&n); | ^~~~~~~~~~~~~~ main.c:8:26: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | for(r=0;r<n;r++) scanf("%d",&w[r]); | ^~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h> int cmp(const void *a,const void *b){ return *(int*)a-*(int*)b; } int main(){ int n,w[128],r,l,re,le; scanf("%d",&n); for(r=0;r<n;r++) scanf("%d",&w[r]); qsort(w,n,sizeof(int),cmp); r=w[0]; l=w[n-1]; re=1; le=n-2; while(re<=le){ if(l>r){ r+=w[re]; re++; }else{ l+=w[le]; le--; } } if(r==l) printf("possible\n"); else printf("impossible\n"); return 0; }