P7302求调
  • 板块灌水区
  • 楼主LuCat_qwq
  • 当前回复0
  • 已保存回复0
  • 发布时间2022/1/9 19:54
  • 上次更新2023/10/28 12:34:44
查看原帖
P7302求调
649256
LuCat_qwq楼主2022/1/9 19:54
#include <bits/stdc++.h>
#define N 105
#define T 1115
using namespace std;
int w,h,scr[T][N],f[T][N],ts;
int nxt[T][N];
int dp(int a,int b){
    if(a>ts) return 0;
    if(~f[a][b]) return f[a][b];
    int r=0;int n=0;
    for(int i=-2; i<=2; ++i){
        if(b+i<1||b+i>w) continue;
        int tmp=dp(a+1,b+i)+scr[a+1][b+i];
        if(tmp>r)r=tmp,n=i;
    }
    f[a][b]=r;
	nxt[a][b]=n;
    return r;
}
void dfs(int a,int b){
    if(a>ts) return;
    if(!f[a][b]) return;
    cout<<nxt[a][b];
    dfs(a+1,b+nxt[a][b]);
}
int main( ){
//  freopen("freepizza.in","r",stdin);
//  freopen("freepizza.out","w",stdout);
    cin>>w>>h;
    int a,b,c,d;
    while(cin>>a>>b>>c>>d){
        if((h-1)%c==0||a==0){
            int t=(h-1)/c+a;
            ts=max(ts,t);
            scr[t][b]+=d;
        }
    }
    memset(f,-2,sizeof(f));
    int ans=dp(0,(w+1)*2);
    cout<<ans;
    dfs(0,(w+1)*2);
    return 0;
}
2022/1/9 19:54
加载中...