結果

問題 No.27 板の準備
ユーザー AuroraAurora
提出日時 2022-05-12 17:42:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 719 bytes
コンパイル時間 1,296 ms
コンパイル使用メモリ 165,900 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-27 17:17:46
合計ジャッジ時間 2,615 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
4,376 KB
testcase_01 AC 5 ms
4,376 KB
testcase_02 AC 7 ms
4,376 KB
testcase_03 AC 6 ms
4,376 KB
testcase_04 AC 7 ms
4,376 KB
testcase_05 AC 7 ms
4,380 KB
testcase_06 AC 8 ms
4,376 KB
testcase_07 AC 8 ms
4,376 KB
testcase_08 AC 10 ms
4,376 KB
testcase_09 AC 9 ms
4,376 KB
testcase_10 AC 8 ms
4,380 KB
testcase_11 AC 7 ms
4,376 KB
testcase_12 AC 8 ms
4,376 KB
testcase_13 AC 7 ms
4,376 KB
testcase_14 AC 7 ms
4,376 KB
testcase_15 AC 7 ms
4,380 KB
testcase_16 AC 6 ms
4,376 KB
testcase_17 AC 7 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
  vector<int> V(4);
  for(int i=0;i<4;i++) cin >> V[i];
  int ans = 1000000000;
  for(int A=1;A<=30;A++){
    for(int B=1;B<=30;B++){
      for(int C=1;C<=30;C++){
        int cnt = 0;
        for(int i=0;i<4;i++){
          int Min = 10000000;
          for(int a=0;a<=30;a++){
            for(int b=0;b<=30;b++){
              int count = a+b;
              int res = V[i]-A*a-B*b;
              if(res < 0) break;
              if(res%C == 0){
                count += res/C;
                Min = min(Min,count);
              }
            }
          }
          cnt += Min;
        }
        ans = min(ans,cnt);
      }
    }
  }
  cout << ans << endl;
}
0