Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:邪门了,NlgN比N还快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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator