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