結果
問題 | No.5 数字のブロック |
ユーザー |
![]() |
提出日時 | 2020-12-26 00:57:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 5,000 ms |
コード長 | 366 bytes |
コンパイル時間 | 2,490 ms |
コンパイル使用メモリ | 196,248 KB |
最終ジャッジ日時 | 2025-01-17 07:26:52 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int l, n; cin >> l >> n; vector<int> w(n); for (int i = 0; i < n; i++) cin >> w.at(i); sort(w.begin(), w.end()); int sum = 0; for (int i = 0; i < n; i++) { sum += w.at(i); if (sum > l) { cout << i << '\n'; return 0; } } cout << n << '\n'; return 0; }