結果
問題 | No.5 数字のブロック |
ユーザー |
|
提出日時 | 2023-02-10 18:05:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 5,000 ms |
コード長 | 433 bytes |
コンパイル時間 | 694 ms |
コンパイル使用メモリ | 77,592 KB |
最終ジャッジ日時 | 2025-02-10 11:57:20 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> int main() { int L, N; std::cin >> L >> N; std::vector<int> W(N); for (int i = 0; i < N; i++) { std::cin >> W[i]; }; std::sort(W.begin(), W.end()); int ans = 0; int width_sum = 0; for (auto &w: W) { width_sum += w; if (width_sum > L) { break; }; ans++; } std::cout << ans << std::endl; }