結果

問題 No.115 遠足のおやつ
コンテスト
ユーザー ふやけももんが
提出日時 2025-12-24 09:20:57
言語 C++17
(gcc 13.3.0 + boost 1.89.0)
結果
TLE  
実行時間 -
コード長 1,100 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,808 ms
コンパイル使用メモリ 194,984 KB
実行使用メモリ 10,920 KB
最終ジャッジ日時 2025-12-24 09:21:07
合計ジャッジ時間 9,105 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 TLE * 1 -- * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using namespace std;

vector<int> answer;
int n,d,k;

int seek(int left,int need, int cost){
    //cout << left << " " << need << " " << cost << endl;

    if(need == 1){
        if( cost == left){
            answer.push_back(left);
            return 1;
        }
        return 0;
    }
    
    if(n-left + 1 < need){
        return 0;
    }
    if( cost > (n+(n-need+1))*need/2){
        // cout << left <<" "<< need<< " " << cost << endl;
        //  cout << n+(n-need+1)*need/2<< " "<< cost << endl;
        return 0;
    }

    

    for(int i = left+1;i <=n;i++){
        if(seek(i,need-1,cost -left)){
            answer.push_back(left);
            return 1;
        }
    }
    
    return 0;
}

int main(){
    cin >> n >> d >> k;

    for(int i = 1;i<=n;i++){
       
        if(seek(i,k,d)){
            for(int j = k-1;j >= 0;j--){
                cout << answer[j];
                if( j != 0){
                    cout << " ";
                }
            }
            cout << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    
    
}
0