From ac9c9571af9c1a3ae81f429dd357d14c8a1d0615 Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Sat, 17 Aug 2024 17:04:10 +0800 Subject: [PATCH] update --- day14/P1064/1.ans | 1 + day14/P1064/1.in | 6 +++++ day14/P1064/P1064.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++ day14/P1064/P1064.json | 8 ++++++ day14/P6567/1.ans | 5 ++++ day14/P6567/1.in | 5 ++++ day14/P6567/P6567.cpp | 2 ++ day14/P6567/P6567.json | 8 ++++++ xmake.lua | 6 ++++- 9 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 day14/P1064/1.ans create mode 100644 day14/P1064/1.in create mode 100644 day14/P1064/P1064.cpp create mode 100644 day14/P1064/P1064.json create mode 100644 day14/P6567/1.ans create mode 100644 day14/P6567/1.in create mode 100644 day14/P6567/P6567.json diff --git a/day14/P1064/1.ans b/day14/P1064/1.ans new file mode 100644 index 0000000..e654209 --- /dev/null +++ b/day14/P1064/1.ans @@ -0,0 +1 @@ +2200 \ No newline at end of file diff --git a/day14/P1064/1.in b/day14/P1064/1.in new file mode 100644 index 0000000..c62ebf4 --- /dev/null +++ b/day14/P1064/1.in @@ -0,0 +1,6 @@ +1000 5 +800 2 0 +400 5 1 +300 5 1 +400 3 0 +500 2 0 diff --git a/day14/P1064/P1064.cpp b/day14/P1064/P1064.cpp new file mode 100644 index 0000000..9c7f5da --- /dev/null +++ b/day14/P1064/P1064.cpp @@ -0,0 +1,55 @@ +//BUG fix +#include +#include +#include +using namespace std; + +const int MAX_M = (int)3.2e4+5; +int n,m; +int v[MAX_M],p[MAX_M],q[MAX_M]; +int tot=0; +int arr[MAX_M]; +int subNum[MAX_M]; +struct Item{ + int v,p,q; + int subNum; +}items[MAX_M]; +int dp[(int)3.2e4+5]; + +int main(){ + ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); + cin>>n>>m; + + for(int i=1;i<=m;i++){ + cin>>v[i]>>p[i]>>q[i]; + } + for(int i=1;i<=m;i++){ + for(int j=1;j<=m;j++){ + if(q[j]==i){ + items[++tot].v=v[j], + items[tot].p=p[j], + items[tot].q=q[j]; + items[i].subNum++; + } + } + if(q[i]==0){ + items[++tot].v=v[i], + items[tot].p=p[i], + items[tot].q=q[i]; + } + } + for(int i=1;i<=m;i++){ + for(int j=n;j>=0;j--){ + if(items[i].subNum==2&&j>=(items[i+1].v+items[i+2].v)){ + dp[j]=max(dp[j],dp[j-(items[i+1].v+items[i+2].v)]+(items[i+1].v*items[i+1].p)+(items[i+2].v*items[i+2].p)); + }else if((items[i].subNum==2&&j>=items[i+1].v) || (items[i].subNum==1&&j>=items[i+1].v)){ + dp[j]=max(dp[j],dp[j-items[i+1].v]+(items[i+1].v*items[i+1].p)); + }else if(items[i].subNum==2&&j>=items[i+2].v){ + dp[j]=max(dp[j],dp[j-items[i+2].v]+(items[i+2].v*items[i+2].p)); + }else if(j>=items[i].v){ + dp[j] = max(dp[j],dp[j-items[i].v]+items[i].v*items[i].p); + } + } + } + cout< #include #include +#include using namespace std; const int MAX_N = 200+5,MAX_M=1e5+5; diff --git a/day14/P6567/P6567.json b/day14/P6567/P6567.json new file mode 100644 index 0000000..57124c3 --- /dev/null +++ b/day14/P6567/P6567.json @@ -0,0 +1,8 @@ +{ + "files":["P6567.cpp"], + "args":["-O2"], + "tests":[ + {"in":"1.in","ans":"1.ans"} + ], + "runtimeout":100 +} \ No newline at end of file diff --git a/xmake.lua b/xmake.lua index 84766eb..774735b 100644 --- a/xmake.lua +++ b/xmake.lua @@ -189,4 +189,8 @@ target("P6567") target("P1941") set_rundir("day14/P1941") - add_files("day14/P1941/P1941.cpp") \ No newline at end of file + add_files("day14/P1941/P1941.cpp") + +target("P1064") + set_rundir("day14/P1064") + add_files("day14/P1064/P1064.cpp") \ No newline at end of file