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 |
DP第一次AC庆祝一下~ #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'; } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator