結果

問題 No.115 遠足のおやつ
ユーザー d2verbd2verb
提出日時 2015-10-04 12:51:58
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,868 bytes
コンパイル時間 1,072 ms
コンパイル使用メモリ 91,148 KB
実行使用メモリ 7,292 KB
最終ジャッジ日時 2023-09-27 01:56:55
合計ジャッジ時間 2,430 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
4,384 KB
testcase_07 WA -
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 3 ms
4,760 KB
testcase_10 AC 3 ms
5,024 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
4,380 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 1 ms
4,384 KB
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <numeric>
#include <ctime>
#include <bitset>
#include <cctype>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>

using namespace std;

//define
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF (INT_MAX/2)
#define PI (2*acos(0.0))
#define EPS (1e-8)

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;

int dx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, -1, 1};

int N, D, K;
bool solved = false;
int dp[101][1001][10];
vector<int> okashi;

void printokashi(){
  for(int i = 1; i < okashi.size(); i++){
    if(i - 1) cout << " ";
    cout << okashi[i];
  }
  cout << endl;
}

void solve(int n, int k, int d){
  if(solved || k > K || d > D) return;
  if(k == K && d == D) { printokashi(); solved = true; return; }
  if(n > N) return;
  if(dp[n][k][d] != -1) return;
  okashi.push_back(n);
  solve(n + 1, k + 1, d + n);
  okashi.pop_back();
  solve(n + 1, k, d);
  dp[n][k][d] = 1;
}

int main(void){
  ios_base::sync_with_stdio(0);
  cin >> N >> D >> K;
  for(int i = 0; i <= N; i++) for(int j = 0; j <= D; j++){
    for(int k = 0; k <= K; k++) dp[i][j][k] = -1;
  }
  solve(0, -1, 0);
  if(!solved) cout << -1 << endl;
  return 0; 
}
0