結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2019-01-15 00:36:36 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 580 bytes |
コンパイル時間 | 377 ms |
コンパイル使用メモリ | 29,568 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-18 12:48:05 |
合計ジャッジ時間 | 1,265 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include <stdio.h> #include <stdlib.h> int compare(const void *a, const void *b) { return *(short *)a - *(short *)b; } int main(void) { short l,n,*w,i,ans; scanf("%hd",&l); scanf("%hd",&n); w = (short *)malloc(sizeof(short) * n); for (i=0;i<n;i++) { scanf("%hd",&w[i]); } qsort(w,n,sizeof(short),compare); ans = 0; for (i=0;i<n;i++) { l -= w[i]; if (l<0) break; ans++; } printf("%hd\n",ans); return 0; }