結果

問題 No.115 遠足のおやつ
ユーザー pekempeypekempey
提出日時 2015-12-20 14:19:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 1,497 bytes
コンパイル時間 1,250 ms
コンパイル使用メモリ 151,712 KB
実行使用メモリ 18,780 KB
最終ジャッジ日時 2023-08-31 00:36:36
合計ジャッジ時間 3,171 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
17,796 KB
testcase_01 AC 8 ms
18,144 KB
testcase_02 AC 8 ms
17,852 KB
testcase_03 AC 7 ms
18,064 KB
testcase_04 AC 9 ms
18,508 KB
testcase_05 AC 7 ms
17,852 KB
testcase_06 AC 8 ms
17,948 KB
testcase_07 AC 8 ms
18,220 KB
testcase_08 AC 8 ms
17,888 KB
testcase_09 AC 8 ms
17,948 KB
testcase_10 AC 8 ms
18,108 KB
testcase_11 AC 8 ms
17,832 KB
testcase_12 AC 8 ms
18,060 KB
testcase_13 AC 7 ms
17,900 KB
testcase_14 AC 8 ms
17,908 KB
testcase_15 AC 9 ms
18,280 KB
testcase_16 AC 9 ms
18,740 KB
testcase_17 AC 9 ms
18,340 KB
testcase_18 AC 7 ms
18,248 KB
testcase_19 AC 8 ms
18,300 KB
testcase_20 AC 8 ms
18,000 KB
testcase_21 AC 8 ms
18,296 KB
testcase_22 AC 9 ms
18,196 KB
testcase_23 AC 8 ms
17,928 KB
testcase_24 AC 8 ms
18,088 KB
testcase_25 AC 9 ms
18,292 KB
testcase_26 AC 8 ms
18,212 KB
testcase_27 AC 8 ms
18,176 KB
testcase_28 AC 8 ms
18,096 KB
testcase_29 AC 9 ms
18,268 KB
testcase_30 AC 7 ms
18,100 KB
testcase_31 AC 8 ms
18,256 KB
testcase_32 AC 9 ms
18,348 KB
testcase_33 AC 8 ms
18,296 KB
testcase_34 AC 9 ms
18,724 KB
testcase_35 AC 8 ms
18,240 KB
testcase_36 AC 8 ms
18,092 KB
testcase_37 AC 9 ms
18,492 KB
testcase_38 AC 11 ms
18,780 KB
testcase_39 AC 11 ms
18,724 KB
testcase_40 AC 7 ms
17,848 KB
testcase_41 AC 7 ms
17,828 KB
testcase_42 AC 8 ms
17,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(a, b, c, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define rep2(i, a) rep3 (i, 0, a)
#define rep3(i, a, b) for (int i = (a); i < (b); i++)
#define repr(...) GET_MACRO(__VA_ARGS__, repr3, repr2)(__VA_ARGS__)
#define repr2(i, a) repr3 (i, 0, a)
#define repr3(i, a, b) for (int i = (b) - 1; i >= (a); i--)
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
using ll = long long;

bool dp[111][1010][11];
tuple<int, int, bool> pre[111][1010][11];

int main() {
	int N, D, K;
	cin >> N >> D >> K;
	rep (i, 111) rep (j, 1010) rep (k, 11) pre[i][j][k] = make_tuple(-1, -1, false);
	dp[0][0][0] = true;
	rep (i, N) rep (j, D + 1) rep (k, K + 1) {
		if (chmax(dp[i + 1][j][k], dp[i][j][k])) {
			pre[i + 1][j][k] = make_tuple(j, k, false);
		}
		if (j + i + 1 <= D && k + 1 <= K){
			if (chmax(dp[i + 1][j + i + 1][k + 1], dp[i][j][k])) {
				pre[i + 1][j + i + 1][k + 1] = make_tuple(j, k, true);
			}
		}
	}
	vector<int> ans;
	tuple<int, int, bool> curr(D, K, false);
	repr (i, N) {
		if (get<2>(pre[i + 1][get<0>(curr)][get<1>(curr)])) {
			ans.push_back(i + 1);
		}
		curr = pre[i + 1][get<0>(curr)][get<1>(curr)];
	}
	if (ans.empty()) ans.push_back(-1);
	reverse(ans.begin(), ans.end());
	rep (i, ans.size()) cout << ans[i] << " "; cout << endl;
	return 0;
}
0