結果
| 問題 |
No.156 キャンディー・ボックス
|
| コンテスト | |
| ユーザー |
mag
|
| 提出日時 | 2020-06-14 17:16:59 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 348 bytes |
| コンパイル時間 | 1,608 ms |
| コンパイル使用メモリ | 171,376 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-27 14:03:16 |
| 合計ジャッジ時間 | 2,617 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
int main(){
int n,m; cin>>n>>m;
vector<int> v(n);
rep(i,n) cin>>v[i];
sort(v.begin(), v.end());
int ans=0;
rep(i,n){
m-=v[i];
if(m<=0){
ans=i+1;
break;
}
}
if(m==0) cout << ans << endl;
else cout << ans-1 << endl;
}
mag