結果
問題 | No.5 数字のブロック |
ユーザー | spacenaut |
提出日時 | 2016-05-10 21:39:29 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 177 ms / 5,000 ms |
コード長 | 444 bytes |
コンパイル時間 | 120 ms |
コンパイル使用メモリ | 21,504 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 08:35:00 |
合計ジャッジ時間 | 2,379 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
コンパイルメッセージ
main.c: In function ‘main’: 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:11:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%d", &w[i]); | ^~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> int main(void){ int l, n, i, j, k, s, te; int cnt = 0; scanf("%d%d", &l, &n); int w[10000] = {}; for(i = 0; i < n; i++){ scanf("%d", &w[i]); } for(j = 0; j < n; j++){ for(k = 0; k < n - 1 - j; k++){ if(w[k] > w[k + 1]){ te = w[k]; w[k] = w[k + 1]; w[k + 1] = te; } } } for(s = 0; l > 0 && s < n; s++){ l -= w[s]; cnt++; } if(l < 0) cnt--; printf("%d", cnt); return 0; }