結果
| 問題 |
No.115 遠足のおやつ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-12 04:54:01 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 712 bytes |
| コンパイル時間 | 1,005 ms |
| コンパイル使用メモリ | 68,296 KB |
| 最終ジャッジ日時 | 2025-01-09 17:37:16 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
#include <iostream>
bool judge(int l, int r, int k, int d) {
if (r - l + 1 < k) return false;
int low = 0, high = 0;
for (int i = 0; i < k; ++i) {
low += l + i;
high += r - i;
}
return low <= d && d <= high;
}
void solve() {
int n, d, k;
std::cin >> n >> d >> k;
if (!judge(1, n, k, d)) {
std::cout << -1 << std::endl;
return;
}
for (int i = 1; i <= n; ++i) {
if (judge(i + 1, n, k - 1, d - i)) {
std::cout << i << " ";
--k;
d -= i;
}
}
std::cout << std::endl;
}
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
solve();
return 0;
}