結果
問題 |
No.115 遠足のおやつ
|
ユーザー |
![]() |
提出日時 | 2018-10-20 16:44:20 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
MLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 513 bytes |
コンパイル時間 | 1,726 ms |
コンパイル使用メモリ | 157,324 KB |
実行使用メモリ | 816,480 KB |
最終ジャッジ日時 | 2025-01-03 01:32:49 |
合計ジャッジ時間 | 87,102 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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) || D < K*(K+1)/2){ cout << -1; }else{ for(int it:ans) cout << it << ' '; } cout << endl; }