結果

問題 No.27 板の準備
ユーザー yuppe19 😺yuppe19 😺
提出日時 2015-05-28 22:47:59
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,125 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 32,372 KB
最終ジャッジ日時 2023-08-27 03:26:56
合計ジャッジ時間 697 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:3: error: ‘vector’ was not declared in this scope
   vector<int> v(4);
   ^~~~~~
main.cpp:12:3: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
main.cpp:3:1:
+#include <vector>
 using namespace std;
main.cpp:12:3:
   vector<int> v(4);
   ^~~~~~
main.cpp:12:10: error: expected primary-expression before ‘int’
   vector<int> v(4);
          ^~~
main.cpp:13:40: error: ‘v’ was not declared in this scope
   for(int i : range(4)) { scanf("%d", &v[i]); }
                                        ^
main.cpp:18:16: error: expected primary-expression before ‘int’
         vector<int> dp(N, inf);
                ^~~
main.cpp:20:28: error: ‘dp’ was not declared in this scope
           if(x % a == 0) { dp[x] = min(dp[x], x / a); }
                            ^~
main.cpp:21:28: error: ‘dp’ was not declared in this scope
           if(x % b == 0) { dp[x] = min(dp[x], x / b); }
                            ^~
main.cpp:22:28: error: ‘dp’ was not declared in this scope
           if(x % c == 0) { dp[x] = min(dp[x], x / c); }
                            ^~
main.cpp:25:15: error: ‘dp’ was not declared in this scope
               dp[n] = min(dp[n], dp[p] + dp[n-p]);
               ^~
main.cpp:25:15: note: suggested alternative: ‘p’
               dp[n] = min(dp[n], dp[p] + dp[n-p]);
               ^~
               p
main.cpp:30:20: error: ‘dp’ was not declared in this scope
             tmp += dp[v[i]];
                    ^~
main.cpp:30:23: error: ‘v’ was not declared in this scope
             tmp += dp[v[i]];
                       ^

ソースコード

diff #

#include <cstdio>
#include <algorithm>
using namespace std;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

const int inf = 19921223;
const int N = 33;

int main(void) {
  vector<int> v(4);
  for(int i : range(4)) { scanf("%d", &v[i]); }
  int res = inf;
  for(int a : range(1, N)) {
    for(int b : range(a+1, N)) {
      for(int c : range(b+1, N)) {
        vector<int> dp(N, inf);
        for(int x : range(N)) {
          if(x % a == 0) { dp[x] = min(dp[x], x / a); }
          if(x % b == 0) { dp[x] = min(dp[x], x / b); }
          if(x % c == 0) { dp[x] = min(dp[x], x / c); }
          for(int n : range(N)) {
            for(int p : range(n)) {
              dp[n] = min(dp[n], dp[p] + dp[n-p]);
            }
          }
          int tmp = 0;
          for(int i : range(4)) {
            tmp += dp[v[i]];
          }
          res = min(res, tmp);
        }
      }
    }
  }
  printf("%d\n", res);
  return 0;
}
0