結果
問題 | No.156 キャンディー・ボックス |
ユーザー |
![]() |
提出日時 | 2015-12-09 19:08:42 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 451 bytes |
コンパイル時間 | 589 ms |
コンパイル使用メモリ | 71,812 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 15:44:55 |
合計ジャッジ時間 | 1,345 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <iostream> #include <vector> #include <math.h> #include <stdio.h> #include <algorithm> #include <string> #include <map> using namespace std; #define ll long long int main() { int n,m; cin >> n >> m; int c[n]; for(int i = 0; i < n; i++) { cin >> c[i]; } sort(c,c+n); int count = 0; int id = 0; while(1) { if(id >= n || c[id] > m) break; m -= c[id]; c[id++] = 0; count++; } cout << count << endl; }