結果
| 問題 |
No.156 キャンディー・ボックス
|
| コンテスト | |
| ユーザー |
stack9996
|
| 提出日時 | 2015-08-26 15:51:39 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 430 bytes |
| コンパイル時間 | 603 ms |
| コンパイル使用メモリ | 61,360 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-05 09:18:09 |
| 合計ジャッジ時間 | 1,438 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <numeric>
#include <algorithm>
#include <string>
#include <vector>
#define rep(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
int n, m;
int c[100001];
int main(){
std::cin >> n >> m;
rep(i, n)std::cin >> c[i];
std::sort(c, c + n);
int cnt = 0;
rep(i, n){
m -= c[i];
++cnt;
if (m <= 0){
if (m < 0)--cnt;
break;
}
}
std::cout << cnt << std::endl;
return 0;
}
stack9996