結果

問題 No.115 遠足のおやつ
ユーザー 👑 CleyL
提出日時 2020-03-02 04:14:13
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 375 bytes
コンパイル時間 468 ms
コンパイル使用メモリ 65,732 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-13 20:54:53
合計ジャッジ時間 1,446 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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