結果

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

ソースコード

diff #

#include <iostream>
using namespace std;
int main(){
  int n,d,k;cin>>n>>d>>k;
  if(n < k || k*(k+1)/2 > d || (n-k+1)*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