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:求大牛指点啊。。为什么我这样会超时啊。。感觉和别人ac的算法没多大的区别啊。。。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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator