結果
問題 | No.156 キャンディー・ボックス |
ユーザー |
![]() |
提出日時 | 2016-05-23 09:32:56 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 674 bytes |
コンパイル時間 | 757 ms |
コンパイル使用メモリ | 100,612 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 15:49:59 |
合計ジャッジ時間 | 1,599 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <vector> #include <string> #include <algorithm> #include <numeric> #include <iostream> #include <cstdlib> #include <cstring> #include <cmath> #include <utility> #include <list> #include <functional> #include <queue> #include <map> #include <iterator> #include <iomanip> #include <complex> using namespace std; using ull = unsigned long long; using ll = long long; int main() { int n,m; cin >> n >> m; vector<int> c(n); for(auto&& x : c) cin >> x; sort(c.begin(),c.end()); for(int i = 0; i < n; ++i) { if(m >= c.at(i)) { m -= c.at(i); } else { cout << i << endl; return 0; } } cout << n << endl; }