結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2017-01-18 11:06:37 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 374 bytes |
コンパイル時間 | 705 ms |
コンパイル使用メモリ | 75,032 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 00:55:29 |
合計ジャッジ時間 | 1,706 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; }