結果
問題 |
No.156 キャンディー・ボックス
|
ユーザー |
![]() |
提出日時 | 2018-10-05 20:51:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 403 bytes |
コンパイル時間 | 1,604 ms |
コンパイル使用メモリ | 171,580 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-12 12:46:13 |
合計ジャッジ時間 | 2,802 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 2 |
other | AC * 12 WA * 18 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:20:13: warning: 'rel' may be used uninitialized [-Wmaybe-uninitialized] 20 | cout << rel << endl; | ^~~ main.cpp:12:9: note: 'rel' was declared here 12 | int rel; | ^~~
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int n,m; cin >> n >> m; vector<int> C; for(int i=0; i < n; i++){ int x; cin >> x; C.push_back(x); } sort(C.begin(), C.end()); int sum=0; int rel; for(int i=0; i < n; i++){ sum += C[i]; if(sum >= m){ rel = i; break; } } cout << rel << endl; }