// No.115 遠足のおやつ // https://yukicoder.me/problems/no/115 // #include #include #include #include using namespace std; vector solve(int N, int D, int K); int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int N, D, K; cin >> N >> D >> K; vector ans = solve(N, D, K); stringstream ss; for (auto a: ans) ss << a << " "; ss << "\b" << endl; cout << ss.str(); } vector solve(int N, int D, int K) { int total_min = (1 + K) * K / 2; int total_max = (N-K+1 + N) * K / 2; if (D < total_min) return vector {-1}; if (D > total_max) return vector {-1}; vector res(K); for (int i = 0; i < K; ++i) res[i] = i+1; int max_n = N; int last_r = K - 1; int diff = D - accumulate(res.begin(), res.end(), 0); while (diff != 0) { if (diff <= (max_n - res[last_r])) { res[last_r] += diff; break; } else { res[last_r] = max_n; --max_n; --last_r; diff = D - accumulate(res.begin(), res.end(), 0); } } return res; }