結果
問題 | No.5 数字のブロック |
ユーザー | ashipan |
提出日時 | 2020-04-17 19:17:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 5,000 ms |
コード長 | 482 bytes |
コンパイル時間 | 761 ms |
コンパイル使用メモリ | 74,192 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-03 10:31:19 |
合計ジャッジ時間 | 1,780 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #define rep(i, a, n) for(int i = a; i < n; i++) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int l, n; cin >> l >> n; vector<int> w(n); rep(i, 0, n){ cin >> w[i]; } sort(w.begin(), w.end()); int sum = 0; int ans = 0; rep(i, 0, n){ sum += w[i]; if(sum > l) break; ans++; } cout << ans << endl; return 0; }