From 8561d633fc61ffc06654da46d3057a6bfe7308c8 Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Sat, 17 Aug 2024 11:20:38 +0800 Subject: [PATCH] update --- day13/P1049/P1049.cpp | 21 ++++++++++++++++++++- day14/P4141/P4141.cpp | 32 ++++++++++++++++++++++++++++++++ day14/P6567/P6567.cpp | 19 +++++++++++++++++++ test.cpp | 10 ++-------- xmake.lua | 10 +++++++++- 5 files changed, 82 insertions(+), 10 deletions(-) create mode 100644 day14/P4141/P4141.cpp create mode 100644 day14/P6567/P6567.cpp diff --git a/day13/P1049/P1049.cpp b/day13/P1049/P1049.cpp index 9d96f53..678ce7d 100644 --- a/day13/P1049/P1049.cpp +++ b/day13/P1049/P1049.cpp @@ -1,10 +1,29 @@ +//AC +#include #include #include +#include using namespace std; +const int MAX_N=30+5; +const int MAX_V=2e4+5; +int V,n; +int w[MAX_N]; +int dp[MAX_V]; + +int readint(); int main(){ - + V=readint(),n=readint(); + for(int i=1;i<=n;i++){ + w[i]=readint(); + } + for(int i=1;i<=n;i++){ + for(int j=V;j>=w[i];j--){ + dp[j]=max(dp[j],dp[j-w[i]]+w[i]); + } + } + cout< +#include +using namespace std; + +const int MAX_N=2e3+5; +int n,m; +int w[MAX_N]; +int dp[MAX_N],g[MAX_N]; + +int main(){ + ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); + cin>>n>>m; + for(int i=1;i<=n;i++){ + cin>>w[i]; + } + dp[0]=1;//背包容量为0也是一种选择方案 + for(int i=1;i<=n;i++){ + for(int j=m;j>=w[i];j--){ + dp[j]=(dp[j]+dp[j-w[i]])%10; + } + } + for(int i=1;i<=n;i++){ + g[0]=1;//背包容量为0也是一种选择方案 + for(int j=1;j<=m;j++){ + if(j +#include +using namespace std; + +const int MAX_N = 200+5,MAX_M=1e5+5; +int n,m; +int k[MAX_N],a[MAX_N],t[MAX_M]; + +int main(){ + ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); + cin>>n>>m; + for(int i=1;i<=n;i++){ + cin>>k[i]>>a[i]; + } + for(int i=1;i<=m;i++){ + cin>>t[i]; + } + +} \ No newline at end of file diff --git a/test.cpp b/test.cpp index 40587ad..040561a 100644 --- a/test.cpp +++ b/test.cpp @@ -1,13 +1,7 @@ #include +#include using namespace std; int main(){ - sets; - s.insert(2); - s.insert(3); - auto it = s.lower_bound(2); - cout<<(*(--it))<