結果
| 問題 |
No.156 キャンディー・ボックス
|
| コンテスト | |
| ユーザー |
MoritaYasuaki
|
| 提出日時 | 2016-05-09 01:21:52 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 449 bytes |
| コンパイル時間 | 112 ms |
| コンパイル使用メモリ | 21,376 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-05 15:49:49 |
| 合計ジャッジ時間 | 1,001 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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);
return 0;
}
MoritaYasuaki