結果

問題 No.27 板の準備
ユーザー LayCurse
提出日時 2014-11-01 23:55:48
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 555 bytes
コンパイル時間 1,588 ms
コンパイル使用メモリ 157,556 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-26 10:25:57
合計ジャッジ時間 2,174 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |   rep(i,n) scanf("%d",V+i);
      |            ~~~~~^~~~~~~~~~

ソースコード

diff #

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

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define INF 100000

int V[4];
int dp[1000];

int main(){
  int i, j, k, n=4;
  int res = INF, tmp;
  int a[3];

  rep(i,n) scanf("%d",V+i);

  REP(a[0],1,31) REP(a[1],a[0]+1,31) REP(a[2],a[1]+1,31){
    rep(i,35) dp[i] = INF;
    dp[0] = 0;
    rep(k,3) REP(i,a[k],35) dp[i] = min(dp[i], dp[i-a[k]]+1);

    tmp = 0;
    rep(i,n) tmp += dp[V[i]];
    res = min(res, tmp);
  }

  printf("%d\n",res);

  return 0;
}
0