結果

問題 No.115 遠足のおやつ
ユーザー ngtkana
提出日時 2020-03-25 23:57:27
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 712 bytes
コンパイル時間 1,870 ms
コンパイル使用メモリ 192,020 KB
最終ジャッジ日時 2025-01-09 10:10:58
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint N,D,K;std::cin>>N>>D>>K;
    if(N==K){
        if(N*(N+1)/2==D){
            for(lint i=1;i<=N;i++){
                std::cout<<(1<i?" ":"")<<i;
            }
            std::cout<<'\n';
        }else{
            std::cout<<-1<<'\n';
        }
        return 0;
    }
    D-=K*(K+1)/2;
    if(D<0||K*(N-K)<D){
        std::cout<<-1<<'\n';
        return 0;
    }
    lint q=D/(N-K),r=D%(N-K);
    for(lint i=1;i<=K;i++){
        std::cout<<(1<i?" ":"")<<i+(i<=K-q-1?0:i==K-q?r:N-K);
    }
    std::cout<<'\n';
}
0