結果

問題 No.115 遠足のおやつ
ユーザー kapokapo
提出日時 2016-05-27 21:21:08
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 653 bytes
コンパイル時間 603 ms
コンパイル使用メモリ 63,960 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 17:47:31
合計ジャッジ時間 1,885 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
using namespace std;

int main(void)
{
	int N, D, K, f=0;
	cin >> N >> D >> K;
	vector<vector<int> > V (1001, vector<int>());
	vector<int> t;

	rep(i,1,N+1) {
		for(int j=1000; j >= 0; j--) {
			if(j && !V[j].size()) continue;
			if(j+i > 1000) continue; 
			if(V[j].size() >= K-1 && j+i != D) continue;
			if(V[j].size() <= K-2 && j+i == D) continue;

			t = V[j];
			t.pb(i);
			if(!V[j+i].size() || V[j+i] > t) V[j+i] = t;
		}
	}

	if(!V[D].size()) cout << -1 << endl;
	else {
		for(auto i: V[D]) cout << i << " ";
	}
	cout << endl;

	return 0;
}
0