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

Re:我也是超内存啊 没有节操啊

Posted by ls_smith at 2012-07-27 16:52:39 on Problem 1062
In Reply To:为什么我的超内存啊,我都用邻接表了,还不行啊 Posted by:panning025 at 2012-07-20 19:33:25
#include<stdio.h>
int m,n;
int k[100],key;
int g[100][3];
int s[100][100][2];

int min(int x)
{
	int i,MIN=10001,mm;
	MIN=g[x][0];
	mm=g[x][0];
	for (i=0;i<g[x][2];i++)
	{
		if(k[s[x][i][0]-1]==1)
		{
			if(s[x][i][1]<mm)
			{
				mm=s[x][i][1]+min(s[x][i][0]-1);
			}
		}
		//printf("%d\n",mm);
		if(mm<MIN)MIN=mm;
	}
	return MIN;
}

int main()
{
	int i,j;
	int mm;
	scanf("%d %d",&m,&n);
	scanf("%d %d %d",g[0],g[0]+1,g[0]+2);
	for (j=0;j<g[0][2];j++)
	{
		scanf("%d %d",s[0][j],s[0][j]+1);
	}
	key=g[0][1];
	k[0]=1;
	for (i=1;i<n;i++)
	{
		scanf("%d %d %d",g[i],g[i]+1,g[i]+2);
		for (j=0;j<g[i][2];j++)
		{
			scanf("%d %d",s[i][j],s[i][j]+1);
		}
		if (key-g[i][1]<=m)
			k[i]=1;
		else
			k[i]=0;
	}
	mm=min(0);
	printf("%d\n",mm);
	return 0;
}

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