結果

問題 No.115 遠足のおやつ
ユーザー koba-e964koba-e964
提出日時 2015-06-07 16:55:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 971 bytes
コンパイル時間 509 ms
コンパイル使用メモリ 67,380 KB
実行使用メモリ 7,728 KB
最終ジャッジ日時 2023-08-31 00:33:19
合計ジャッジ時間 2,106 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 3 ms
6,396 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 3 ms
4,900 KB
testcase_10 AC 3 ms
5,040 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 3 ms
6,012 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 3 ms
6,244 KB
testcase_16 AC 3 ms
6,196 KB
testcase_17 AC 2 ms
5,800 KB
testcase_18 AC 2 ms
5,576 KB
testcase_19 AC 2 ms
5,768 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
5,736 KB
testcase_22 AC 3 ms
6,284 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
6,028 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
5,892 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 3 ms
5,812 KB
testcase_30 AC 3 ms
6,200 KB
testcase_31 AC 3 ms
5,900 KB
testcase_32 AC 3 ms
6,240 KB
testcase_33 AC 2 ms
5,700 KB
testcase_34 AC 4 ms
6,396 KB
testcase_35 AC 3 ms
6,016 KB
testcase_36 AC 2 ms
4,500 KB
testcase_37 AC 3 ms
6,308 KB
testcase_38 AC 6 ms
7,728 KB
testcase_39 AC 6 ms
7,724 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS=1e-9;

int dp[101][1010][11];

int main(void){
  int n, d, k;
  cin >> n >> d >> k;
  dp[n][0][0] = 1;
  for (int i = n - 1; i >= 0; --i) {
    REP(j, 0, d + 1) {
      REP(l, 0, k + 1) {
	dp[i][j][l] = dp[i + 1][j][l];
	if (j >= i + 1 && l >= 1) {
	  dp[i][j][l] |= dp[i + 1][j - i - 1][l - 1];
	}
      }
    }
  }
  if (dp[0][d][k] == 0) {
    cout << -1 << endl;
    return 0;
  }
  int cur = d, curk = k;
  REP (i, 0, n) {
    if (curk > 0 && dp[i + 1][d - i - 1][curk - 1]) {
      cout << i + 1;
      if (curk > 1) {
	cout << " ";
      }
      d -= i + 1;
      curk--;
    }
  }
  cout << endl;
}
0