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 |
为什么,在source的测试都对了,在这就不对呢//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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator