結果

問題 No.115 遠足のおやつ
ユーザー dazy
提出日時 2018-06-20 01:49:55
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 409 bytes
コンパイル時間 1,874 ms
コンパイル使用メモリ 159,572 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2025-01-03 01:29:39
合計ジャッジ時間 3,183 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int n, d, k;
    cin >> n >> d >> k;
    if(k*(k+1)/2>d ||n*k-(k-1)*k/2<d) printf("-1\n");
    else {
        for(int i=1; k; i++) {
            if(n*(k-1)-(k-2)*(k-1)/2>=d-i) {
                if(k==1 && d-i!=0) continue;
                printf("%d ", i);
                k--;
                d-=i;
            }
        }
    }
    return 0;
}
0