update
This commit is contained in:
parent
74b1065e5a
commit
ac9c9571af
1
day14/P1064/1.ans
Normal file
1
day14/P1064/1.ans
Normal file
@ -0,0 +1 @@
|
||||
2200
|
6
day14/P1064/1.in
Normal file
6
day14/P1064/1.in
Normal file
@ -0,0 +1,6 @@
|
||||
1000 5
|
||||
800 2 0
|
||||
400 5 1
|
||||
300 5 1
|
||||
400 3 0
|
||||
500 2 0
|
55
day14/P1064/P1064.cpp
Normal file
55
day14/P1064/P1064.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
//BUG fix
|
||||
#include <algorithm>
|
||||
#include <ios>
|
||||
#include <iostream>
|
||||
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<<dp[n]<<endl;
|
||||
}
|
8
day14/P1064/P1064.json
Normal file
8
day14/P1064/P1064.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"files":["P1064.cpp"],
|
||||
"args":["-O2","-Wall"],
|
||||
"tests":[
|
||||
{"in":"1.in","ans":"1.ans"}
|
||||
],
|
||||
"runtimeout":1000
|
||||
}
|
5
day14/P6567/1.ans
Normal file
5
day14/P6567/1.ans
Normal file
@ -0,0 +1,5 @@
|
||||
No
|
||||
Yes
|
||||
No
|
||||
Yes
|
||||
Yes
|
5
day14/P6567/1.in
Normal file
5
day14/P6567/1.in
Normal file
@ -0,0 +1,5 @@
|
||||
3 5
|
||||
1 2
|
||||
5 1
|
||||
6 3
|
||||
3 19 21 1 7
|
@ -1,5 +1,7 @@
|
||||
#include <chrono>
|
||||
#include <ios>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
using namespace std;
|
||||
|
||||
const int MAX_N = 200+5,MAX_M=1e5+5;
|
||||
|
8
day14/P6567/P6567.json
Normal file
8
day14/P6567/P6567.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"files":["P6567.cpp"],
|
||||
"args":["-O2"],
|
||||
"tests":[
|
||||
{"in":"1.in","ans":"1.ans"}
|
||||
],
|
||||
"runtimeout":100
|
||||
}
|
Loading…
Reference in New Issue
Block a user