結果
問題 | No.115 遠足のおやつ |
ユーザー |
![]() |
提出日時 | 2017-04-28 22:25:01 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 1,116 bytes |
コンパイル時間 | 1,965 ms |
コンパイル使用メモリ | 157,456 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2025-01-03 01:24:01 |
合計ジャッジ時間 | 3,150 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define FOR(i,a,b) for(int i=(a);i<(b);i++)#define REP(i,n) FOR(i,0,n)#define ALL(v) (v).begin(),(v).end()template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }typedef unsigned long long ull;typedef long long ll;typedef pair<int, int> pii;typedef pair<ll, ll> pll;typedef pair<int, pii> P;const ll INF = 1ll<<60;const ll MOD = 1000000007;const double EPS = 1e-10;int main() {int N, D, K;cin >> N >> D >> K;vector<int> ans;int last = 0, sum = 0, cnt = 0;if (N < K) puts("-1");else if ( (N - (K - 1) + N) * K / 2 < D || (1 + K) * K / 2 > D) puts("-1");else {while (ans.size() < K) {FOR(i, last + 1, N + 1) {int next = D - sum - i;if ((N - (K - cnt - 2) + N) * (K - cnt - 1) / 2 >= next) {ans.push_back(i);last = i;sum += i;cnt++;break;}}}REP(i, K) printf("%d%c", ans[i], i == K - 1 ? '\n' : ' ');}return 0;}