結果
問題 |
No.156 キャンディー・ボックス
|
ユーザー |
![]() |
提出日時 | 2022-12-17 15:07:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 378 bytes |
コンパイル時間 | 1,978 ms |
コンパイル使用メモリ | 191,256 KB |
最終ジャッジ日時 | 2025-02-09 15:12:46 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; int n,m,a[20],ans; int main(){ cin>>n>>m; for(int i=0;i<n;++i) cin>>a[i]; for(int i=n-1;i>0;--i) for(int j=0;j<i;++j) if(a[j]>a[j+1]) swap(a[j],a[j+1]); for(int i=0;i<n;++i){ m-=a[i]; if(m<0) break; ++ans; } cout<<ans<<endl; return 0; }