二话没说上去搜索 , 果不其然 华丽超时 .

 #include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<cctype>
#include<limits.h>
using namespace std;
int a[][],result,n,m;
void DFS(int y,int x,int step)
{
if(y<||y>n||x<||x>m)
return;
if(y==n&&x==m&&step>result)
result=step;
DFS(y+,x,step+a[y+][x]);
DFS(y,x+,step+a[y][x+]);
}
int main()
{
while(scanf("%d%d",&n,&m)!=EOF)
{
for(int i=;i<n;i++)
for(int j=;j<m;j++)
scanf("%d",&a[i][j]);
result=INT_MIN;
DFS(,,a[][]);
printf("%d\n",result);
}
return ;
}

还是用DP吧 .   只用了 4ms   ...

 #include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<cctype>
#include<limits.h>
using namespace std;
int dp[][],result,n,m;
int main()
{
while(scanf("%d%d",&n,&m)!=EOF)
{
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
scanf("%d",&dp[i][j]);
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
dp[i][j]=dp[i][j]+max(dp[i][j-],dp[i-][j]);
printf("%d\n",dp[n][m]);
}
return ;
}

聪明的kk --- 搜索超时的更多相关文章

  1. nyoj 171 聪明的kk

    聪明的kk 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 聪明的“KK”非洲某国展馆的设计灵感源于富有传奇色彩的沙漠中陡然起伏的沙丘,体现出本国不断变换和绚丽多彩的 ...

  2. 聪明的kk

    聪明的kk 时间限制:1000 ms  |  内存限制:65535 KB 难度:3 描写叙述 聪明的"KK" 非洲某国展馆的设计灵感源于富有传奇色彩的沙漠中陡然起伏的沙丘.体现出本 ...

  3. NYoj_171聪明的kk

    聪明的kk 时间限制:1000 ms  |  内存限制:65535 KB 难度:3 描述 聪明的"KK" 非洲某国展馆的设计灵感源于富有传奇色彩的沙漠中陡然起伏的沙丘,体现出本国不 ...

  4. nyoj 聪明的kk

    聪明的kk 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述 聪明的"KK"非洲某国展馆的设计灵感源于富有传奇色彩的沙漠中陡然起伏的沙丘,体现出本国 ...

  5. NYOJ-171 聪明的kk 填表法 普通dp

    题目链接: http://acm.nyist.edu.cn/JudgeOnline/problem.php?pid=171 聪明的kk 时间限制:1000 ms  |  内存限制:65535 KB 难 ...

  6. E 聪明的“KK”

    Description 非洲某国展馆的设计灵感源于富有传奇色彩的沙漠中陡然起伏的沙丘,体现出本国不断变换和绚丽多彩的自然风光与城市风貌.展馆由五部分组成,馆内影院播放名为<一眨眼的瞬间>的 ...

  7. NYOJ-171 聪明的kk AC 分类: NYOJ 2014-01-02 09:01 165人阅读 评论(0) 收藏

    #include<stdio.h> #define max(x,y) x>y?x:y int main(){ int num[22][22]={0}; int n,m; int x, ...

  8. [河南省ACM省赛-第三届] 聪明的kk (nyoj 171)

    题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=171 动态规划: d(i,j) = max{d(i-1, j), d(i, j-1)}+m ...

  9. 聪明的kk (南洋理工—171)

    #include<iostream> using namespace std; ][]; ][]; int N, M; int dp(int i, int j) { ) return d[ ...

随机推荐

  1. idea搭建maven项目 【转发】

    为了创建maven项目可是花了我时间了,网上的教程跟我的实际情况不符合,尤其是facets .artifacts 那块.幸亏找到这篇文章没解决了我的问题,他的描述跟我的情况一模一样.这篇文章竟然来自百 ...

  2. Missing message for key "xxx" in bundle "(default bundle)" for locale zh_CN

    参考文章http://programmerslounge.blogspot.com/2013/03/error-missing-message-for-key.html 错误的struts-confi ...

  3. xfce 安装文泉驿字体

    下载文泉驿字体 #拷贝字体到目录/usr/share/fonts/wqy#创建字体缓存 mkfontscale # 在当前目录下生成fonts.scale文件 mkfontdir # 在当前目录下生成 ...

  4. Python-函数和代码复用

    函数的定义与使用 >函数的理解与定义 函数是一段代码的表示 -函数是一段具有特定功能的.可重用的语句组 -函数是一种功能的抽象,一般函数表达特定功能 -两个作用:降低编程难度 和 代码复用 de ...

  5. 洛谷 1328 生活大爆炸版石头剪刀布(NOIp2014提高组)

    [题解] 简单粗暴的模拟题. #include<cstdio> #include<algorithm> #include<cstring> #define LL l ...

  6. CF2B The least round way

    [题解] 可以发现10的因数除了1和10之外只有2和5了,那么走过的路径上各个数字的2的因数个数之和.5的因数个数之和中较小的一个即是答案.这样的话DP即可.同时需要注意有0的情况,有0的时候有一个答 ...

  7. 【Codeforces 242C】King's Path

    [链接] 我是链接,点我呀:) [题意] 让你找到(x0,y0)到(x1,y1)的一条最短路 走过的点必须在所给的n个横向路径上 [题解] 因为n条横向路径上的点最多不会超过10的5次方个,所以我们可 ...

  8. yarn & vue-cli

    yarn & vue-cli https://github.com/xgqfrms/ES6/issues/10 install https://yarnpkg.com/zh-Hans/docs ...

  9. noip模拟赛 梦想

    题目描述 LYK做了一个梦. 这个梦是这样的,LYK是一个财主,有一个仆人在为LYK打工. 不幸的是,又到了月末,到了给仆人发工资的时间.但这个仆人很奇怪,它可能想要至少x块钱,并且当LYK凑不出恰好 ...

  10. android安卓程序源码---高仿微信源码

    先截几张图: 部份源代码如下所示: package cn.buaa.myweixin; import java.util.ArrayList; import android.os.Bundle; im ...