結果

問題 No.115 遠足のおやつ
ユーザー motimoti
提出日時 2015-07-17 00:53:10
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,085 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 78,060 KB
最終ジャッジ日時 2024-04-27 02:08:33
合計ジャッジ時間 1,028 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp:17:29: error: ‘chmin’ function uses ‘auto’ type specifier without trailing return type
   17 | template<class T> constexpr auto chmin(T& x, T a) { x = min(x, a); }
      |                             ^~~~
main.cpp:17:29: note: deduced return type only available with ‘-std=c++14’ or ‘-std=gnu++14’

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <set>
#include <map>

using namespace std;

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

typedef long long ll;

template<class T> constexpr auto chmin(T& x, T a) { x = min(x, a); }

vector<int> dp[105][1101][15];

const vector<int> def = {99,99,99,99};

ostream& operator << (ostream& ost, vector<int>& v) {
  if(v == def) { ost << -1; }
  else {
    rep(i, v.size()) {
      if(i) cout << " ";
      ost << v[i];
    }
  }
  return ost;
}

int main() {

  int N, D, K; cin >> N >> D >> K;

  rep(i, 105) rep(j, 1101) rep(k, 15) { dp[i][j][k] = def; }

  dp[0][0][0] = {};
  rep(i, N+1) {
    rep(j, 1001) {
      rep(k, 11) {
        if(dp[i][j][k] != def) {
          vector<int> nvec = dp[i][j][k]; nvec.push_back(i+1);
          chmin(dp[i+1][j][k], dp[i][j][k]);
          chmin(dp[i+1][j+i+1][k+1], nvec);
//          cout << dp[i+1][j+i+1][k+1] << endl;
        }
      }
    }
  }

  cout << dp[N][D][K] << endl;

  return 0;
}
0