| ||||||||||
| 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:大牛讲下0ms怎么实现啊??In Reply To:大牛讲下0ms怎么实现啊?? Posted by:cmonkey at 2009-07-18 22:56:16 #include <cstdlib>
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
/*
*
*/
int matrix[100][100];
int f,v;
void pku_1157()
{
scanf("%d%d",&f,&v);
for(int i=0;i<f;++i)
for(int j=0;j<v;++j)
scanf("%d",&matrix[i][j]);
int tmp;
for(int i=1;i<f;++i){
for(int j=i;j<=v-f+i;++j){
if(j-2>=0 && matrix[i-1][j-1]<matrix[i-1][j-2]){
tmp = matrix[i-1][j-2];
matrix[i-1][j-2] = matrix[i-1][j-1];
matrix[i-1][j-1]=tmp;
}
matrix[i][j] +=matrix[i-1][j-1];
}
}
int max=matrix[f-1][f-1];
for(int j=f-1;j<v;++j)
if(max<matrix[f-1][j])max=matrix[f-1][j];
printf("%d\n",max);
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator