結果
問題 |
No.156 キャンディー・ボックス
|
ユーザー |
![]() |
提出日時 | 2016-05-09 01:21:16 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 435 bytes |
コンパイル時間 | 853 ms |
コンパイル使用メモリ | 20,608 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-05 10:59:21 |
合計ジャッジ時間 | 1,404 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
コンパイルメッセージ
main.c:10:1: warning: return type defaults to ‘int’ [-Wimplicit-int] 10 | comp(const void *va, const void *vb) { | ^~~~ main.c:16:1: warning: return type defaults to ‘int’ [-Wimplicit-int] 16 | main() { | ^~~~ main.c: In function ‘main’: main.c:17:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 17 | scanf("%td%td", &N, &M); | ^~~~~~~~~~~~~~~~~~~~~~~ main.c:20:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | scanf("%td",&C[n]); | ^~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <stdlib.h> #include <stddef.h> #define int ptrdiff_t int N, M; int C[10]; comp(const void *va, const void *vb) { const int *a = va; const int *b = vb; return *a - *b; } main() { scanf("%td%td", &N, &M); int n = N; while (n--) scanf("%td",&C[n]); qsort(C, N, sizeof(int), comp); while (M > 0) M -= C[n++]; if (M) n--; printf("%td\n", n); }