結果
問題 | No.5 数字のブロック |
ユーザー |
![]() |
提出日時 | 2018-06-11 16:57:40 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 442 bytes |
コンパイル時間 | 537 ms |
コンパイル使用メモリ | 64,364 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-30 13:36:03 |
合計ジャッジ時間 | 1,508 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 WA * 14 |
ソースコード
#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{ cout << count; return 0; } } return 0; }