結果
問題 | No.156 キャンディー・ボックス |
ユーザー |
![]() |
提出日時 | 2015-06-11 09:02:44 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 479 bytes |
コンパイル時間 | 526 ms |
コンパイル使用メモリ | 64,636 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 09:16:05 |
合計ジャッジ時間 | 1,521 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <iostream> #include <algorithm> #include <vector> using namespace std; typedef long long LL; const LL MOD=1000000007; int main(){ LL N, M; cin >> N >> M; vector<LL> box(N); for(int i = 0; i < N; i++){ cin >> box[i]; } sort(box.begin(), box.end()); int ans = 0; for(int i = 0; i < box.size(); i++){ if(M >= box[i]){ M -= box[i]; ans = i+1; } } cout << ans << endl; return 0; }