結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2016-12-26 03:08:56 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 296 bytes |
コンパイル時間 | 105 ms |
コンパイル使用メモリ | 20,736 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-18 10:49:16 |
合計ジャッジ時間 | 1,104 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:11:9: warning: implicit declaration of function ‘qsort’ [-Wimplicit-function-declaration] 11 | 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%d",&l,&n); | ^~~~~~~~~~~~~~~~~~~ main.c:9:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d",&w[i]); | ^~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h> int cmp(const void*a,const void *b){ return *(int*)a-*(int*)b; } int main(){ int i,l,n,w[10000],s=0; scanf("%d%d",&l,&n); for(i=0;i<n;i++){ scanf("%d",&w[i]); } qsort(w,n,sizeof(int),cmp); for(i=0;i<n;i++){ s+=w[i]; if(s>l) break; } printf("%d\n",i); return 0; }