| ||||||||||
| 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 | |||||||||
昨晚动态凌晨2:30,郁闷了。今天这题,一次编译,一次提交AC了,情绪一下子就爆发了。贴出代码#include<stdio.h>
int op[2][102];
int max;
int a[102][102];
int main()
{
int f,v;
int i,j;
while(scanf("%d%d",&f,&v)!=EOF)
{
for(i=0;i<f;i++)
for(j=0;j<v;j++)
scanf("%d",&a[i][j]);
for(i=0;i<f;i++)
{
max=-100;
for(j=i;j<=v-f+i;j++)
{
if(i==0)
op[i][j]=a[0][j];
else
{
if(op[(i-1)%2][j-1]>max)
max=op[(i-1)%2][j-1];
op[i%2][j]=max+a[i][j];
}
}
}
max=0;
for(i=v-f;i<v;i++)
{
if(op[(f-1)%2][i]>max)
max=op[(f-1)%2][i];
}
printf("%d\n",max);
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator