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

为什么用DM还超时呢?

Posted by impala at 2006-10-04 19:56:31 on Problem 2997
rt

code:



#include "iostream"
#include "string.h"
#include "stdio.h"
using namespace std;

main()
{
	
	char c[10003]={'\0'};
	int  p[1000]={0};
	int i;
	char o;
	p[105]=1; p[118]=5; p[120]=10; p[108]=50; p[99]=100; p[100]=500; p[109]=1000;
	int t;
	int l=0;
	int n;
	int po, pi;
	while (gets(c))
	{
		long h[10001][3]={0};
		l=0;
		n=strlen(c);
		pi=0;
		po=1;
		for (i=0; i<n ;i++)
		{
			if (p[c[i]])
			{
				l++;
				h[l][1]=h[l][0]=p[c[i]];
			}
		}
		int j, k;
		long tot=0;
		long y=0;
		for (i=po+1;i<=l;i++)
		{
			for (j=po;j<i;j++)
				if ((h[i][0]<h[j][0])&&(h[i][0]+h[j][1]>h[i][1]))
				{
						h[i][1]=h[i][0]+h[j][1];
				}
		}
		cout<<h[l][1]<<endl;
	}
	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