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:求大牛指点啊。。为什么我这样会超时啊。。感觉和别人ac的算法没多大的区别啊。。。

Posted by bluesky_ at 2014-07-11 22:09:18 on Problem 3262
In Reply To:求大牛指点啊。。为什么我这样会超时啊。。感觉和别人ac的算法没多大的区别啊。。。 Posted by:crc19930320 at 2013-07-16 17:14:05
> #include<iostream>
> #include<algorithm>
> #include<cstdlib>
> using namespace std;
> 
> struct cow
> {
>     int t;
>     int d;
>     double p;
> };
> 
> bool cmp(cow a, cow b)
> {
>     return b.p > a.p;
> }
> cow c[10002];
> 
> int main()
> {
>     int n, i, s = 0;
>     long long sum = 0;
>     cin >> n;
>     for(i = 0;i < n;i ++)
>     {
>         cin >>c[i].t>>c[i].d;
>         c[i].p = 1.00 * c[i].t / (c[i].d * 1.00);
>         s += c[i].d;
>     }
>     sort(c,c + n, cmp);
>     for(i = 0;i < n - 1;i ++)
>     {
>         s -= c[i].d;
>         sum += c[i].t * s;
>     }
>     sum <<=1;
>     cout << sum<<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