結果
| 問題 |
No.115 遠足のおやつ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-01-07 03:33:38 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 800 bytes |
| コンパイル時間 | 1,796 ms |
| コンパイル使用メモリ | 163,124 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2025-01-03 01:27:29 |
| 合計ジャッジ時間 | 3,251 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n) - 1; (i) >= 0; --i)
#define SZ(n) (int)(n).size()
#define ALL(n) (n).begin(), (n).end()
#define MOD 1000007
#define INF 100000000
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;
int main() {
int n, d, k;
cin >> n >> d >> k;
if (d < (k + 1) * k / 2 || d > n * k - k * (k - 1) / 2) {
cout << -1 << endl;
return 0;
}
VI a;
REP(i, k) a.push_back(i + 1);
int i[2] = {};
i[0] = k - 1; i[1] = n;
while (1) {
int t = 0;
for (int e : a) t += e;
if (t == d) break;
a[i[0]]++;
if (a[i[0]] == i[1]) {
i[1] = a[i[0]] - 1;
i[0]--;
}
}
for (int e : a) cout << e << " ";
cout << endl;
return 0;
}