結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2019-10-29 17:46:24 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 746 bytes |
コンパイル時間 | 545 ms |
コンパイル使用メモリ | 66,136 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-14 21:33:44 |
合計ジャッジ時間 | 1,541 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 29 WA * 5 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; //関数プロトタイプ宣言 void Input(int&, int&, vector<int>&); int main() { //各パラメータ int L; //箱の幅 int N; //個数 int count = 0; vector<int> W; //幅の配列 //パラメータの入力 Input(L, N, W); //各幅の配列を昇順に並べる sort(W.begin(), W.end()); if (N == 1) { if (L - W[0] >= 0) { cout << 1 << endl; } else { cout << 0 << endl; } } for (int i = 0; i < N; i++) { L -= W[i]; if (L < 0) { break; } count++; } cout << count << endl; } void Input(int& L, int& N, vector<int>& W) { int w; cin >> L; cin >> N; for (int i = 0; i < N; i++) { cin >> w; W.push_back(w); } }