結果
問題 |
No.115 遠足のおやつ
|
ユーザー |
![]() |
提出日時 | 2020-03-28 19:14:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 619 bytes |
コンパイル時間 | 1,840 ms |
コンパイル使用メモリ | 166,716 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2025-01-02 12:01:37 |
合計ジャッジ時間 | 3,216 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 2 WA * 38 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int n, d, k; cin >> n >> d >> k; int sum = 0; vector<int> ans; for (int i = 1; i <= n; i++) { if (ans.size() == k - 1) { ans.push_back(d - sum); break; } else { ans.push_back(i); sum += i; } } sort(ans.begin(), ans.end()); bool ok = true; for (int i = 0; i+1 < ans.size(); i++) { ok &= (ans[i] != ans[i+1]); } if (ok) { for (const auto &e : ans) cout << e << '\n'; } else { cout << -1 << endl; } return 0; }