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

为什么,在source的测试都对了,在这就不对呢

Posted by ssq at 2006-03-05 00:02:05 on Problem 2063
//pku 2063 Investment 

#include<iostream>
#include<string.h>
//#include<fstream>
using namespace std;
//thanks for hust_acm 
//his code is wonderful that perfectly solve more complex package
#define in cin
//ifstream in("f.in");
//ifstream in1("f.out");
#define SIZE 50000
int income[SIZE]={0};
int bargin[14][2];
int testcase;
int initMoney;
int year;
int totalbargins;
main()
{
	int i,j,k,y;
	int m;

	int premoney;
	int max;
	int b;
	int start;
	in>>testcase;
	for(i = 1; i<= testcase; i++)
	{
		in>>initMoney>>year>>totalbargins;
		start = initMoney/1000;
		income[0] = 0;
		for(j = 1; j<= SIZE; j++)
			income[j] = -1;
		m = initMoney/1000; 
		premoney = 0;
		for( j = 1; j <= totalbargins; j++)
		{
			in>>bargin[j][0]>>bargin[j][1];
		}
		for( j = 1; j <= totalbargins; j++)
		{
			bargin[j][0]/=1000;
		}
		max = 0;
		for(y = 1; y<=year; y++)
		{
			m = initMoney/1000;
			for(j = premoney+1; j<= m ; j++)
			{
				for(k = 1; k<=totalbargins; k++)
				{
					b = bargin[k][0];
					if(j>=b && income[ j-b ] + bargin[k][1] > income[j] && income[j-b]>=0)
						income[j] = income[ j-b ] + bargin[k][1];
				}
				if(max < income[j])
					max = income[j];
			}
			premoney = m;
			initMoney += max;
		}
		cout<<initMoney<<endl;
		
		
	}
	return 1;
}

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