結果

問題 No.115 遠足のおやつ
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2014-12-28 23:35:39
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,319 bytes
コンパイル時間 773 ms
コンパイル使用メモリ 89,988 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-03 18:49:47
合計ジャッジ時間 2,292 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 2 ms
4,376 KB
testcase_03 RE -
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 RE -
testcase_07 AC 2 ms
4,380 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 RE -
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 RE -
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 1 ms
4,376 KB
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(long long i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
 
#define MOD 1000000007

int main(){
  int n,d,k;
  cin>>n>>d>>k;
  int a;
  a=0;
  rep(i,1,k+1){
    a+=i;
  }
  if(a>d){
    cout << -1 << endl;
    return -1;
  }
  a=0;
  rep(i,n-k+1,n+1){
    a+=i;
  }
  if(a<d){
    cout << -1 << endl;
    return -1;
  }
  vector<int> v;
  rep(i,1,k+1){
    v.pb(i);
  }
  reverse(all(v));
  f:;
  for(;;){
    a=0;
    rep(i,0,v.sz){
      a+=v[i];
    }
    if(a==d){
      reverse(all(v));
      rep(i,0,v.sz){
        cout << v[i];
        if(i == v.sz-1){
          cout << endl;
        }
        else{
          cout << " ";
        }
      }
      return 0;
    }
    rep(i,0,v.sz){
      if(v[i] < n-i){
        v[i]++;
        goto f;
      }
    }
  }
  return 0;
}
0