結果
問題 |
No.156 キャンディー・ボックス
|
ユーザー |
![]() |
提出日時 | 2019-02-22 19:41:39 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 313 bytes |
コンパイル時間 | 799 ms |
コンパイル使用メモリ | 64,332 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-24 23:34:33 |
合計ジャッジ時間 | 1,321 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 2 |
other | AC * 6 WA * 24 |
ソースコード
#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; } } }