From 8aba3d8e3d8077c7efc62c77c5d51e3bca5d3908 Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Thu, 11 Sep 2025 11:46:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0P5017=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E7=9A=84=E5=8A=A8=E6=80=81=E8=A7=84=E5=88=92=E8=A7=A3?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 实现了一个基于深度优先搜索和记忆化的动态规划解决方案,用于解决P5017问题。该算法通过排序输入数据并利用记忆化技术优化计算,有效减少了重复计算,提高了效率。 --- src/9/11/P5017.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/9/11/P5017.cpp diff --git a/src/9/11/P5017.cpp b/src/9/11/P5017.cpp new file mode 100644 index 0000000..7e218e2 --- /dev/null +++ b/src/9/11/P5017.cpp @@ -0,0 +1,46 @@ +#include +#include +#include +#include +#include +using ll = int64_t; + +ll n,m, maxt=0; +std::vector t; +std::vector> mem; + +static inline ll dfs(const ll cur,const ll st){ + if(cur>=n+1)return 0; + if(st>n>>m; + t.resize(n+1); + mem.resize(n+1,std::vector(maxt+m+1)); + for(ll i=1;i<=n;i++){ + std::cin>>t[i]; + } + std::sort(t.begin()+1,t.begin()+1+n); + std::cout<