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 |
为什么我的一直Memory Limit Exceeded!!数组开的不大呀?求高手解答!#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator