結果
| 問題 |
No.27 板の準備
|
| コンテスト | |
| ユーザー |
ty70
|
| 提出日時 | 2015-06-25 03:55:52 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 5,000 ms |
| コード長 | 1,621 bytes |
| コンパイル時間 | 1,605 ms |
| コンパイル使用メモリ | 88,804 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-26 10:34:03 |
| 合計ジャッジ時間 | 1,675 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm> // require sort next_permutation count __gcd reverse etc.
#include <cstdlib> // require abs exit atof atoi
#include <cstdio> // require scanf printf
#include <functional>
#include <numeric> // require accumulate
#include <cmath> // require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip> // require setw
#include <sstream> // require stringstream
#include <cstring> // require memset
#include <cctype> // require tolower, toupper
#include <fstream> // require freopen
#include <ctime> // require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define INF 1<<20
/*
No.27 板の準備
全探索、全探索?
*/
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int solve (int a, int b, int c, int v ){
int res = INF;
for (int x = 0; x <= v/a; x++ ){
for (int y = 0; y <= v/b; y++ ){
for (int z = 0; z <= v/c; z++ ){
if (a*x + b*y + c*z == v ){
res = min (res, x + y + z );
} // end if
} // end for
} // end for
} // end for
return res;
}
int main()
{
ios_base::sync_with_stdio(0);
vector<int> V(4, 0 );
rep (i, 4 ) cin >> V[i];
int res = INF;
for (int a = 1; a <= 30; a++ ){
for (int b = a + 1; b <= 30; b++ ){
for (int c = b + 1; c <= 30; c++ ){
int curr = 0;
rep (i, 4 )
curr += solve (a, b, c, V[i] );
res = min (res, curr );
} // end for
} // end for
} // end for
cout << res << endl;
return 0;
}
ty70