結果

問題 No.115 遠足のおやつ
ユーザー tanimani364tanimani364
提出日時 2021-03-10 16:42:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,344 bytes
コンパイル時間 1,885 ms
コンパイル使用メモリ 199,400 KB
実行使用メモリ 9,108 KB
最終ジャッジ日時 2024-04-20 12:02:45
合計ジャッジ時間 3,301 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,960 KB
testcase_01 AC 4 ms
9,088 KB
testcase_02 WA -
testcase_03 AC 4 ms
8,928 KB
testcase_04 WA -
testcase_05 AC 3 ms
8,960 KB
testcase_06 AC 4 ms
8,768 KB
testcase_07 AC 4 ms
8,848 KB
testcase_08 AC 3 ms
9,088 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 4 ms
8,884 KB
testcase_12 WA -
testcase_13 AC 4 ms
8,872 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 3 ms
8,848 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 3 ms
8,848 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 3 ms
8,976 KB
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 4 ms
8,880 KB
testcase_41 AC 4 ms
8,988 KB
testcase_42 AC 3 ms
8,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

//using lll=boost::multiprecision::cpp_int;
//using Double=boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1024>>;//仮数部が1024桁
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

template <typename T>
T mypow(T x, T n, const T &p = -1)
{ //x^nをmodで割った余り

	if(p!=-1){
		x%=p;
	}
	T ret = 1;
	while (n > 0)
	{
		if (n & 1)
		{
			if (p != -1)
				ret = (ret * x) % p;
			else
				ret *= x;
		}
		if (p != -1)
			x = (x * x) % p;
		else
			x *= x;
		n >>= 1;
	}
	return ret;
}

using namespace std;
//using namespace atcoder;

bool dp[101][1001][11];
int pre[101][1001][11];
void solve()
{	
	int n,d,k;
	cin>>n>>d>>k;
	memset(dp,false,sizeof(dp));
	memset(pre,-1,sizeof(pre));
	dp[0][0][0]=true;
	rep(i,n){
		rep(j,k+1){
			rep(x,d+1){
				if(j+1<=k&&x+(i+1)<=d&&dp[i][j][x]){
					dp[i+1][j+1][x+(i+1)]=true;
					pre[i+1][j+1][x+(i+1)]=x;
				}
				dp[i+1][j][x]|=dp[i][j][x];
			}
		}
	}

	if(dp[n][k][d]){
		int pos=n;
		int used=k;
		int cur=d;
		vector<int>ans;
		while(pos>0){
			if(pre[pos][used][cur]==-1){
				--pos;
				continue;
			}
			int val=cur-pre[pos][used][cur];
			if(val&&val==pos){
				ans.eb(val);

				cur=pre[pos][used][cur];
				used--;
			}
			--pos;
		}
		reverse(all(ans));
		rep(i,ans.size()){
			cout<<ans[i]<<(i==ans.size()-1?"\n":" ");
		}
	}else{
		cout<<-1<<"\n";
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}
0