結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2017-09-21 17:12:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 568 bytes |
コンパイル時間 | 1,067 ms |
コンパイル使用メモリ | 78,984 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-18 11:43:18 |
合計ジャッジ時間 | 1,891 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <cstdio> #include <cstring> #include <cmath> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); 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 s = 0; for (int i = 0; i < n; i++) { s += w[i]; if (s > l) { cout << i << endl; quick_exit(0); } } cout << n << endl; return 0; }