結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2016-03-05 05:22:47 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 120 ms / 5,000 ms |
コード長 | 600 bytes |
コンパイル時間 | 102 ms |
コンパイル使用メモリ | 21,248 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 08:18:32 |
合計ジャッジ時間 | 1,682 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:5:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 5 | scanf("%d",&l); | ^~~~~~~~~~~~~~ main.c:6:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | scanf("%d",&n); | ^~~~~~~~~~~~~~ main.c:8:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | scanf("%d",&w[i]); | ^~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> void smaller_sort(int *a,int cnt); int main(void){ int l,n,w[10000],i,cnt,sum; scanf("%d",&l); scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d",&w[i]); } smaller_sort(w,n); sum=0; cnt=0; for(i=0;i<n;i++){ sum+=w[i]; if(sum>l){ break; }else{ cnt++; } } printf("%d\n",cnt); return 0; } void smaller_sort(int *a,int cnt){ int i,j,buf; for(i=0;i<cnt-1;i++){ for(j=cnt-1;j>i;j--){ if(*(a+j)<*(a+j-1)){ buf=*(a+j-1); *(a+j-1)=*(a+j); *(a+j)=buf; } } } }