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:邪门了,NlgN比N还快

Posted by liu_cheng_ao at 2016-09-09 13:30:52 on Problem 2393
In Reply To:邪门了,NlgN比N还快 Posted by:tracyhenry at 2009-07-22 22:58:32
> O(NlogN)的16ms,O(N)的63ms
我O(N)的是0ms
#include<cstdio>

using namespace std;

int y[11000],f[11000],n,s;

int main()
{
	scanf("%d%d",&n,&s);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&f[i],&y[i]);
	for(int i=1;i<n;i++)
		f[i+1]=f[i+1]<f[i]+s?f[i+1]:f[i]+s;
	long long sum=0;
	for(int i=1;i<=n;i++)
		sum+=f[i]*y[i];
	printf("%lld",sum);
	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