zoukankan      html  css  js  c++  java
  • [暑假集训]开训复健练习赛 D

    #include<iostream>
    #include<stdio.h>
    #include<cstring>
    #include<vector>
    #include<algorithm>
    #define DEBUG if(0)//方便测试
    #define MAX 100010
    using namespace std;
    int N;
    int map[2][MAX][15];
    int f(int x,int y){
        if(x<max(0,5-y) || x>min(10,y+5) || y<0)return 0;//超出可拾取范围
        if(map[1][y][x]>=0)return map[1][y][x]; //已经计算过
        map[1][y][x]=max(f(x-1,y-1),max(f(x,y-1),f(x+1,y-1)));//从上方找出最大值
        return map[1][y][x]+=map[0][y][x];//加上当前项
    }
    int main(){
        while(cin>>N,N>0){
            int a=0,b=0,maxt=0;
            memset(map[0],0,sizeof(map[0]));
            memset(map[1],-1,sizeof(map[1]));
            for(int i=0;i<N;i++){
                scanf("%d%d",&a,&b);
    
                map[0][b][a]++;//该位置可以拾取到一个
                if(maxt<b)maxt=b;//记录总时间
            }
            
            DEBUG cout<<maxt<<endl;
            DEBUG{
                for(int i=0;i<=maxt;i++){
                    for(int j=0;j<=10;j++){
                        cout<<map[0][i][j]<<" ";
                    }//输出记录的地图
                    cout<<endl;
                }
            }
            
            int maxans=0;
            for(int i=0;i<=10;i++){
                if(maxans<f(i,maxt))//从计算出的表最下方找出最大的
                    maxans=f(i,maxt);
            }
            DEBUG{cout<<endl;;
                for(int i=0;i<=maxt;i++){
                    for(int j=0;j<=10;j++){
                        if(map[1][i][j]>=0)//输出表
                            cout<<map[1][i][j]<<" ";
                        else 
                            cout<<"#"<<" ";//好看!
                    }
                    cout<<endl;
                }
            }
            cout<<maxans<<endl;
    
        };
    
        return 0;
    }

    https://vjudge.net/contest/382410#problem/D

  • 相关阅读:
    ZOJ 2158 Truck History
    Knight Moves (zoj 1091 poj2243)BFS
    poj 1270 Following Orders
    poj 2935 Basic Wall Maze (BFS)
    Holedox Moving (zoj 1361 poj 1324)bfs
    ZOJ 1083 Frame Stacking
    zoj 2193 Window Pains
    hdu1412{A} + {B}
    hdu2031进制转换
    openjudge最长单词
  • 原文地址:https://www.cnblogs.com/forwhat00/p/13303363.html
Copyright © 2011-2022 走看看