結果

問題 No.115 遠足のおやつ
ユーザー kappybarkappybar
提出日時 2020-03-28 11:27:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,165 bytes
コンパイル時間 1,836 ms
コンパイル使用メモリ 173,124 KB
実行使用メモリ 7,556 KB
最終ジャッジ日時 2023-08-30 17:31:55
合計ジャッジ時間 3,358 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 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 AC 2 ms
4,380 KB
testcase_22 WA -
testcase_23 AC 1 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 AC 6 ms
7,556 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;


int main() {
    int n,d,k;
    cin >> n >> d >> k;
    vector<vector<vector<int>>> dp(n+1,vector<vector<int>>(k+1,vector<int>(d+1,0)));
    dp[0][0][0] = 1;
    for(int i =1;i <=n;i++){
        rep(cnt,k+1)rep(value,d+1){
            dp[i][cnt][value] += dp[i-1][cnt][value];
            if(value - i >= 0 && cnt -1 >= 0){
                dp[i][cnt][value] += dp[i-1][cnt-1][value-i];
            }
        }
    }

    if(dp[n][k][d] <= 0){
        cout << -1 << endl;
        return 0;
    }

    vector<int> ans;
    int now = n,cnt = k,value = d;
    while(now >= 0){
        if(cnt - 1 >= 0 && value - now >= 0){
            if(dp[now-1][cnt-1][value-now] > 0){
                ans.push_back(now);
                value -= now;now --;cnt --;
            }
            else{
                now --;
            }
        }
        else{
            now --;
        }
    }
    
    reverse(ans.begin(),ans.end());
    rep(i,ans.size()) cout << ans[i] << endl;
    return 0;  
}
0