結果
問題 | No.5 数字のブロック |
ユーザー |
![]() |
提出日時 | 2019-04-23 09:19:04 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 5,000 ms |
コード長 | 516 bytes |
コンパイル時間 | 826 ms |
コンパイル使用メモリ | 75,220 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-18 14:21:47 |
合計ジャッジ時間 | 1,571 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include <iostream> #include <string> #include <cstring> #include <vector> #include <algorithm> #define rep(i, x) for(int (i) = 0; (i) < (x); (i) ++) #define MOD 1000000007 using namespace std; int main(){ int l, n; vector<int> w; cin >> l >> n; rep(i, n){ int wi; cin >> wi; w.push_back(wi); } sort(w.begin(), w.end()); int count = 0, sum = 0; while(true){ if(count == n || sum + w[count] > l){ break; }else{ sum += w[count]; count ++; } } cout << count << endl; return 0; }