結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2016-08-21 21:42:56 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 5 ms / 5,000 ms |
コード長 | 449 bytes |
コンパイル時間 | 537 ms |
コンパイル使用メモリ | 64,448 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-18 08:50:00 |
合計ジャッジ時間 | 1,344 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include <algorithm> #include <iostream> #include <vector> using namespace std; template<typename T> istream& operator >> (istream& is, vector<T>& vec){ for(T& x: vec) is >> x; return is; } int main(int argc, char** argv) { int l, n; cin >> l >> n; vector<int> w(n); cin >> w; sort(w.begin(), w.end()); int ans = 0, sum = 0; while (sum < l && ans < n) sum += w.at(ans++); if(sum > l) ans--; cout << ans << endl; return 0; }