| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:DP第一次ACIn Reply To:DP第一次AC Posted by:shoutz at 2013-04-10 14:37:20 > 庆祝一下~
> #include<iostream>
> #include<algorithm>
> using namespace std;
> int main()
> {
> int f,v;
> int a[110][110];
> int b[110][110];
> for(int i=0;i<100;i++)
> for(int j=0;j<100;j++)
> b[i][j]=-100000;
>
> while(cin>>f>>v)
> {
>
> for(int i=0;i<f;i++)
> for(int j=0;j<v;j++)
> cin>>a[i][j];
> b[0][0]=a[0][0];
> for(int i=1;i<v;i++)
> {
> b[0][i]=max(b[0][i-1],a[0][i]);
> }
> for(int i=1;i<f;i++)
> for(int j=i;j<v;j++)
> {
> b[i][j]=max(b[i-1][j-1]+a[i][j],b[i][j-1]);
> }
> cout<<b[f-1][v-1]<<'\n';
>
> }
> }
数组b的初始化应该放在while循环体内。因为这题是单组测试用例,所以你的代码能A。不过感谢dp公式!!!
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator