結果
問題 | No.156 キャンディー・ボックス |
ユーザー |
![]() |
提出日時 | 2016-09-25 03:21:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 357 bytes |
コンパイル時間 | 1,538 ms |
コンパイル使用メモリ | 170,756 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 15:54:55 |
合計ジャッジ時間 | 2,477 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int N, M; cin >> N >> M; vector<int> vc(N); for( auto&& x : vc ) { cin >> x; } sort( vc.begin(), vc.end() ); int total{},count{}; for( const auto& x : vc ) { if( total <= M ) { if( total + x <= M ) { count++; } total += x; } } cout << count << endl; return 0; }