Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

我考!,数组开[200][200],AC,开[115][115]RE,WHY?

Posted by AC123 at 2010-04-28 17:06:55 on Problem 1050
#include <stdlib.h>
#include<stdio.h>
int d[205][205];
int sum(int i,int j,int k)
{
    int ans=0;
    for(int u=i;u<=j;u++)
        ans+=d[u][k];
    return ans;
}
int main(int argc, char** argv) {
    int n,i,j,r,k;
    while(scanf("%d",&n)!=EOF)
    {
        for(i=1;i<=n;i++)
            for(j=1;j<=n;j++)
                scanf("%d",&d[i][j]);
        int max=d[1][1],ans;
        for(r=1;r<=n;r++)
        {
            for(i=1;i<=n;i++)
            {
                int j=i+r-1;
                ans=0;
                for(k=1;k<=n;k++)
                {
                    ans+=sum(i,j,k);
                    if(ans>max) max=ans;
                    if(ans<0) ans=0;
                }
            }
        }
        printf("%d\n",max);
    }
    return (EXIT_SUCCESS);
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator