結果

問題 No.115 遠足のおやつ
ユーザー cureskolcureskol
提出日時 2020-03-28 13:15:27
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 323 bytes
コンパイル時間 1,511 ms
コンパイル使用メモリ 159,996 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2025-01-03 01:54:43
合計ジャッジ時間 2,750 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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