結果
問題 | No.5 数字のブロック |
ユーザー |
![]() |
提出日時 | 2015-11-29 15:53:10 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 451 bytes |
コンパイル時間 | 236 ms |
コンパイル使用メモリ | 21,760 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-14 05:05:02 |
合計ジャッジ時間 | 1,263 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 WA * 6 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:15:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%d%d\n", &L, &N); | ^~~~~~~~~~~~~~~~~~~~~~~ main.c:20:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | scanf("%d", &w[i]); | ^~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <stdlib.h> int comp(const void *a, const void *b) { return *(int*)a - *(int*) b; } int main() { int i; int L, N; int length = 0, count = 0; scanf("%d%d\n", &L, &N); int w[N]; for (i = 0; i < N; i++) { scanf("%d", &w[i]); } qsort(w, N, sizeof(int), comp); while (length < L) { length += w[count]; count++; } if (length == L) count++; printf("%d\n", count - 1); return 0; }