結果
問題 | No.5 数字のブロック |
ユーザー |
![]() |
提出日時 | 2018-06-11 17:14:04 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 486 bytes |
コンパイル時間 | 622 ms |
コンパイル使用メモリ | 64,400 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 12:28:18 |
合計ジャッジ時間 | 1,443 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#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; } }else if (L == w[i]) { count++; cout << count; return 0; } } cout << count; return 0; }