結果

問題 No.115 遠足のおやつ
ユーザー 👑 CleyL
提出日時 2020-03-02 04:07:25
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 374 bytes
コンパイル時間 465 ms
コンパイル使用メモリ 63,488 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-13 20:54:51
合計ジャッジ時間 1,874 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
int main(){
  int n,d,k;cin>>n>>d>>k;
  if(k*(k+1)/2 > d || n*k+(k*(k+1))/2 < d){
    cout << -1 << endl;
    return 0;
  }
  for(int i = 1; k >= i; i++){
    //買ったときに詰まない最低金額
    int z = max(i,d-((n-k+i)*(k-i)+((k-i)*(k+1-i))/2));
    cout << z;
    d-=z;
    if(i != k)cout << " ";
  }
  cout << endl;
}
0