結果
問題 | No.5 数字のブロック |
ユーザー | k_kiri |
提出日時 | 2019-03-21 10:13:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 5,000 ms |
コード長 | 425 bytes |
コンパイル時間 | 1,727 ms |
コンパイル使用メモリ | 170,992 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-18 13:01:50 |
合計ジャッジ時間 | 2,624 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include <bits/stdc++.h> typedef long long ll; const int INF = 1e9; const ll LINF = 1e18; const int MOD = 1e9 + 7; 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()); ll sum = 0; for (int i = 0; i < n; i++) { sum += w[i]; if (sum > l) { cout << i << endl; return 0; } } cout << n << endl; }