結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2017-01-18 11:01:46 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 374 bytes |
コンパイル時間 | 582 ms |
コンパイル使用メモリ | 65,088 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 00:55:27 |
合計ジャッジ時間 | 1,592 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 10 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int L, N, w, sum = 0, ans = 0; vector<int> W(0); cin >> L >> N; for(int i=0; i<N; i++) { cin >> w; W.push_back(w); } sort(W.begin(), W.end()); while(sum+W[ans]<=L) { sum += W[ans]; ans++; } cout << ans << endl; }