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 KatrineYang at 2016-07-29 22:59:18 on Problem 2063 and last updated at 2016-07-29 23:00:45
開45260就會RE,理论上祘,每年至多增长10%,那麽40年后最多是1000K*1.1^40=45259K,是不會越界的。
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;

int main() {
	int N;
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		int start, year;
		scanf("%d%d", &start, &year);
		int d;
		scanf("%d", &d);
		int bonds[10], it[10];
		for(int j = 0; j < d; j++){
			scanf("%d%d", bonds+j, it+j);
			bonds[j] /= 1000;
		}
		int dp[51200] = {0};
		int MX = (int)((start/1000) * pow(1.1, year)) + 4;
		for(int j = 0; j <= MX; j++){
			int resj = 0;
			for(int k = 0; k < d; k++){
				if(j < bonds[k]) continue;
				int temp = dp[j-bonds[k]] + it[k];
				if(temp > resj) resj = temp;
			}
			dp[j] = resj;
		}
		for(int j = 0; j < year; j++){
			start += dp[start/1000];
		}
		printf("%d\n", start);
	}
	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