結果

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

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