結果
問題 | No.156 キャンディー・ボックス |
ユーザー |
|
提出日時 | 2016-06-02 20:40:21 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 378 bytes |
コンパイル時間 | 441 ms |
コンパイル使用メモリ | 58,704 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 15:50:10 |
合計ジャッジ時間 | 1,277 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <iostream> #include <algorithm> using namespace std; int n; int m; int c[10]; int a_min; int a_index; int cnt = 0; int main(){ cin >> n >> m; for(int i = 0; i < n; i++){ cin >> c[i]; } sort(c, c + n); for(int i = 0; i < n; i++){ m -= c[i]; if(m == 0){ cnt++; break; } if(m < 0){ break; } cnt++; } cout << cnt << endl; }