結果
問題 |
No.156 キャンディー・ボックス
|
ユーザー |
![]() |
提出日時 | 2019-02-22 19:42:50 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 326 bytes |
コンパイル時間 | 526 ms |
コンパイル使用メモリ | 65,420 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-24 23:35:36 |
合計ジャッジ時間 | 1,417 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 14 WA * 16 |
ソースコード
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); int s = 0; for (int i = 0; i < n; i++) { s += a[i]; if (s > k) { cout << i << endl; return 0; } } }