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

这题是贪心吗,求证明……

Posted by ly50247 at 2010-04-17 21:48:49 on Problem 2336
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cstdio>
#include <climits>
#include <queue>
using namespace std;

int data[1500];

int main()
{
	int n;
	scanf("%d", &n);
	while (n--)
	{
		int c, time, m, tim = 0, times = 0;
		scanf("%d%d%d", &c, &time, &m);
		for (int i=0; i < m; i++)
			scanf("%d", data+i);
		if (m % c != 0)
		{
			int tmp = m % c;
			times = m / c + 1;
			tim = data[tmp-1] + time;
			if (tmp != m)
			{
				tim += time;
			for (int i=tmp+c-1; i < m; i+= c)
			{
				if (tim < data[i])
					tim = data[i];
				tim += 2*time;
			}
			tim -= time;
			}

		}
		else
		{
			times = m / c;
			for (int i=c-1; i < m; i+= c)
			{
				if (tim < data[i])
					tim = data[i];
				tim += 2*time;
			}
			tim -= time;
		}
		printf("%d %d\n", tim, times);



	}

	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