为什么你刚注册就可以获得估值卡?
by Studymakesmehappy @ 2019-10-14 07:09:51
@[Studymakesmehappy](/space/show?uid=156091) 估值卡是什么啊
by lk_liang @ 2019-10-14 07:25:57
@[lk_liang](/space/show?uid=103308) 就是这个“萌新”为啥萌新到
rank 681
by Studymakesmehappy @ 2019-10-14 07:39:55
qnmdmx
by G_M_H @ 2019-10-14 07:46:47
@[bellmanford](/space/show?uid=116015)
~~qndmx~~
等不到下一个垃圾就饿死了呢。。。
by Сталин @ 2019-10-14 07:57:14
opt:10
by Сталин @ 2019-10-14 08:00:15
呃,input:
```cpp
20 1
11 20 20
```
by Сталин @ 2019-10-14 08:01:57
@[Studymakesmehappy](/space/show?uid=156091) 可我是真的刚学DP啊
by bellmanford @ 2019-10-14 21:07:16
@[Сталин](/space/show?uid=120905) 改了,还是不对QAQ
代码:
```cpp
//游荡的孤高桀骜的灵魂不需要羁绊之地
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int d,g,mtim=10,ans=0,ans1=10,dp[2][3005];
struct CuCun{
int t,f,h;
}c[1005];
int read(){
int x=0,y=1;
char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-') y=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
x=x*10+ch-'0';
ch=getchar();
}
return x*y;
}
bool cmp(CuCun x,CuCun y){
return x.t<y.t;
}
int main(){
memset(dp,-1,sizeof(dp));
d=read(),g=read();
for(int i=1;i<=g;i++){
c[i].t=read(),c[i].f=read(),c[i].h=read();
mtim+=c[i].f;
if(c[i].t<=ans1) ans1+=c[i].f;
}
sort(c+1,c+g+1,cmp);
dp[0][10]=0;
for(int i=1;i<=g;i++){
for(int j=0;j<=mtim;j++){
if(dp[(i-1)%2][j+(c[i].t-c[i-1].t)]!=-1) dp[i%2][j]=max(dp[i%2][j],dp[(i-1)%2][j+(c[i].t-c[i-1].t)]+c[i].h);
if(dp[(i-1)%2][j+(c[i].t-c[i-1].t)-c[i].f]!=-1) dp[i%2][j]=max(dp[i%2][j],dp[(i-1)%2][j+(c[i].t-c[i-1].t)-c[i].f]);
if(dp[(i-1)%2][j+(c[i].t-c[i-1].t)]==-1&&dp[(i-1)%2][j+(c[i].t-c[i-1].t)-c[i].f]==-1) dp[i%2][j]=-1;
ans=max(ans,dp[i%2][j]);
// printf("%d ",dp[i%2][j]);
}
// printf("\n");
if(ans>=d){
printf("%d\n",c[i].t);
return 0;
}
}
printf("%d\n",ans1);
}
/*
20 1
11 20 20
10
*/
```
by bellmanford @ 2019-10-14 21:08:03
大佬们帮忙康康思路有没有问题,毕竟我刚学QAQ
by bellmanford @ 2019-10-14 21:13:36