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