結果
問題 | No.5 数字のブロック |
ユーザー |
![]() |
提出日時 | 2018-06-11 17:11:18 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 418 bytes |
コンパイル時間 | 614 ms |
コンパイル使用メモリ | 64,288 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-30 13:37:50 |
合計ジャッジ時間 | 1,622 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 WA * 7 |
ソースコード
#include <iostream> #include <algorithm> #include <vector> #define rep(i, n) for(int i = 0; i < (int)(n); i++) using namespace std; int main() { int L, N; cin >> L >> N; vector<int> w(N); rep(i, N) { cin >> w[i]; } sort(w.begin(), w.end()); int count = 0; rep(i, N) { if (L - w[i] > 0) { L -= w[i]; count++; if (L == 0) { cout << count; return 0; } } } cout << count; return 0; }