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

汗,我能过USACO官方数据,却不能ac,加了数据了?

Posted by Felicia at 2008-01-30 22:10:00 on Problem 2184
#include <iostream>
using namespace std;

const int maxint = 0x7FFFFFFF;
typedef long long int64;
const int64 maxint64 = 0x7FFFFFFFFFFFFFFFLL;

const int maxm = 400010;
const int zero = 200000;

int n;
int f[maxm];

int main()
{
	while (scanf("%d", &n) != EOF)
	{
		memset(f, -1, sizeof(f));
		f[zero] = 0;
		for (int i = 0; i < n; i++)
		{
			int t1, t2;
			scanf("%d%d", &t1, &t2);
			if (t1 >= 0)
			{
				for (int j = maxm - 1 - t1; j >= 0; j--)
					if (f[j] != -1)
						f[j + t1] >?= f[j] + t1 + t2;
			}
			else
			{
				for (int j = -t1; j < maxm; j++)
					if (f[j] != -1)
						f[j + t1] >?= f[j] + t1 + t2;
			}
		}
		int ans = 0;
		for (int i = zero; i < maxm; i++)
			if (f[i] - i + zero >= 0)
				ans >?= f[i];
		printf("%d\n", ans);
	}
    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