結果
| 問題 |
No.115 遠足のおやつ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-12-08 17:37:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 644 bytes |
| コンパイル時間 | 1,712 ms |
| コンパイル使用メモリ | 160,480 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2025-01-03 01:33:13 |
| 合計ジャッジ時間 | 3,210 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
bool check(int x, int y, int d, int k) {
if(y - x + 1 < k) {
return false;
}
int low = 0, high = 0;
for(int i = 0; i < k; i++) {
low += x + i;
high += y - i;
}
return low <= d && high >= d;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n, d, k;
cin >> n >> d >> k;
if(check(1, n, d, k)) {
for(int i = 1; i <= n; i++) {
if(check(i + 1, n, d - i, k - 1)) {
if(k == 1) {
cout << i << endl;
return 0;
}
else {
cout << i << " ";
}
d -= i;
k--;
}
}
}
cout << -1 << endl;
return 0;
}