結果
問題 | No.5 数字のブロック |
ユーザー |
![]() |
提出日時 | 2015-09-01 19:56:31 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 379 bytes |
コンパイル時間 | 1,357 ms |
コンパイル使用メモリ | 68,160 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 07:32:17 |
合計ジャッジ時間 | 1,660 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include <iostream> #include <queue> #include <vector> #include <tuple> #include <algorithm> using namespace std; int main() { int L, N; cin >> L >> N; vector<int> W(N); for (int i = 0; i < N; i++) { cin >> W[i]; } sort(W.begin(), W.end()); int i = 0; for (int total = 0; i < N; i++) { total += W[i]; if (total > L) break; } cout << i << endl; return 0; }