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

为什么我的一直Memory Limit Exceeded!!数组开的不大呀?求高手解答!

Posted by 326775408 at 2011-10-27 14:34:13 on Problem 1062
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<cmath>
using namespace std;
struct lift{
	int t[100],v[100];
}a[100];
int price[102],dengji[102],tid[102];
int min(int i,int j){
	if(i>j)return j;
	return i;
}
int max(int i,int j){
	if(i>j)return i;
	return j;
}
int sum=0,min1=1000000,m,nummin;
int sousuo(int n,int dengmin,int dengmax){
	int mm=price[n];
	if(tid[n]==0){
		return mm;
	}
	int i,t=0;
	for(i=0;i<tid[n];i++){
		if(abs(dengmin-dengji[a[n].t[i]-1])>m||abs(dengmax-dengji[a[n].t[i]-1])>m)continue;
		t=min(mm,sousuo(a[n].t[i]-1,min(dengmin,dengji[a[n].t[i]-1]),max(dengmax,dengji[a[n].t[i]-1]))+a[n].v[i]);	
			if(t<mm)mm=t;
	}
	return mm;
}

int main()
{//poj1062
	int n;
	cin>>m>>n;
	int k,l;
	for(k=0;k<n;k++){
		cin>>price[k]>>dengji[k]>>tid[k];
		for(l=0;l<tid[k];l++)
			cin>>a[k].t[l]>>a[k].v[l];
	}
	nummin=dengji[0];
	cout<<sousuo(0,nummin,nummin)<<endl;
	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