結果
問題 |
No.115 遠足のおやつ
|
ユーザー |
![]() |
提出日時 | 2018-10-20 16:38:09 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 495 bytes |
コンパイル時間 | 2,174 ms |
コンパイル使用メモリ | 160,980 KB |
実行使用メモリ | 814,828 KB |
最終ジャッジ日時 | 2024-11-19 02:38:06 |
合計ジャッジ時間 | 77,652 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | MLE * 3 |
other | MLE * 40 |
コンパイルメッセージ
main.cpp: In function ‘bool solve(int, int, int)’: main.cpp:18:10: warning: control reaches end of non-void function [-Wreturn-type] 18 | solve(i+1, k, d); | ~~~~~^~~~~~~~~~~
ソースコード
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; int N, D, K; vector<int> ans; bool solve(int i, int k, int d){ if(d==0) return true; if(N<i) return false; if(d<=i+N*(N+1)/2-(N-k+1)*(N-k+2)/2){ ans.push_back(i); k--; d-=i; } solve(i+1, k, d); } int main(){ cin >> N >> D >> K; if(solve(1, K, D)){ for(int it:ans) cout << it << ' '; }else{ cout << -1; } cout << endl; }