結果
問題 | No.156 キャンディー・ボックス |
ユーザー | AQUA16573837 |
提出日時 | 2018-03-13 00:42:08 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 354 bytes |
コンパイル時間 | 330 ms |
コンパイル使用メモリ | 39,884 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 16:15:15 |
合計ジャッジ時間 | 1,335 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%d %d", &n, &m); | ~~~~~^~~~~~~~~~~~~~~~~ main.cpp:12:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%d", c + i); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <algorithm> #include <deque> using namespace std; using ll = long long; //156 int main() { int n, m, c[11] = { 0 }; scanf("%d %d", &n, &m); for (int i = 0; i < n; i++) scanf("%d", c + i); sort(c, c + n); int blank = 0, ped = 0; while (c[blank] + ped <= m && blank < n) ped += c[blank++]; printf("%d\n", blank); }