結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2018-09-20 00:17:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 594 bytes |
コンパイル時間 | 1,010 ms |
コンパイル使用メモリ | 76,384 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 12:37:30 |
合計ジャッジ時間 | 1,882 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; static void setup() { cin.tie(0); ios::sync_with_stdio(false); } static void run() { int l, n; cin >> l >> n; vector<int> ws; ws.resize(n); for (auto i = 0; i < n; ++i) { cin >> ws[i]; } sort(begin(ws), end(ws)); auto rl = 0; auto rn = 0; for (const auto w : ws) { rl += w; if (rl > l) break; rn += 1; } cout << rn << endl; } int main(int argc, char **argv) { setup(); run(); return 0; }