結果
| 問題 |
No.27 板の準備
|
| コンテスト | |
| ユーザー |
atn112323
|
| 提出日時 | 2016-05-06 19:17:53 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 775 bytes |
| コンパイル時間 | 720 ms |
| コンパイル使用メモリ | 57,676 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-26 12:30:35 |
| 合計ジャッジ時間 | 1,606 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 |
ソースコード
#include <algorithm>
#include <iostream>
using namespace std;
const int INF = 1000;
int V[4];
int num(int L, int A, int B, int C) {
int res = INF;
int nc = L / C;
for (int c = nc; c >= 0; c--) {
int nb = (L - C * c) / B;
for (int b = nb; b >= 0; b--) {
int rest = L - C * c - B * b;
if (rest % A == 0) {
res = min(res, c + b + rest / A);
}
}
}
return res;
}
int num(int A, int B, int C) {
int res = 0;
for (int i = 0; i < 4; i++) {
res += num(V[i], A, B, C);
}
return res;
}
int main() {
for (int i = 0; i < 4; i++) {
cin >> V[i];
}
int mi = INF;
for (int A = 1; A <= 30; A++) {
for (int B = A + 1; B <= 30; B++) {
for (int C = B + 1; C <= 30; C++) {
mi = min(mi, num(A, B, C));
}
}
}
cout << mi << endl;
return 0;
}
atn112323