結果
問題 |
No.115 遠足のおやつ
|
ユーザー |
![]() |
提出日時 | 2023-03-24 14:52:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,087 bytes |
コンパイル時間 | 4,304 ms |
コンパイル使用メモリ | 249,892 KB |
最終ジャッジ日時 | 2025-02-11 16:47:29 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll=long long; using ld=long double; ld pie=3.141592653589793; ll inf=1444999999994; ll mod=1000000007; int main(){ ll n,d,k; cin >> n >> d >> k; vector<ll>a(k); ll sum=0; ll x=0; for (ll i = 0; i < k; i++) { a[i]=i+1; sum+=i+1; x+=n-i; if (i+1>n) { cout << -1 << endl; return 0; } } if (sum>d) { cout << -1 << endl; return 0; } if (x<d) { cout << -1 << endl; return 0; } ll now=sum; ll id=k-1; ll ma=n; while (now!=d) { if (id==-1) { cout << -1 << endl; return 0; } if (ma-a[id]<=d-now) { now+=ma-a[id]; a[id]=ma; ma-=1; id-=1; }else{ a[id]+=d-now; now=d; } } for (ll i = 0; i < k; i++) { cout << a[i] << ' '; } cout << endl; }