結果

問題 No.115 遠足のおやつ
ユーザー なお
提出日時 2014-12-29 01:05:44
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 553 bytes
コンパイル時間 1,352 ms
コンパイル使用メモリ 156,364 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-03 01:01:13
合計ジャッジ時間 2,729 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)           for(int(i)=0;(i)<(n);++(i))

int N,D,K, a[11];

int main(){
    cin >> N >> D >> K;
    int t = 0;
    REP(i,K) a[i] = i+1, t += i+1;

    if(t > D){ cout << -1 << endl; return 0; }

    int l = N, f = D - t;
    for(int i = K-1; i >= 0; i--){
        int d = min(a[i] + f, l) - a[i];
        f -= d; a[i] += d; l--;
    }

    if(f){ cout << -1 << endl; return 0; }

    for(int i = 0; i < K; i++){
        if(i > 0) cout << " ";
        cout << a[i];
    }
    cout << endl;
}
0