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 |
STL水过,RE请注意输入为0的情况代码: #include<queue> #include<cstdio> using namespace std; int n, ans, tail; priority_queue< pair<int, int> > a; priority_queue< int > b; signed main(void) { while (scanf("%d",&n) != EOF) { if (n == 0) { puts("0"); continue; } while (!a.empty())a.pop(); while (!b.empty())b.pop(); for (int i = 1, x, y; i <= n; i++) scanf("%d%d", &x, &y), a.push(make_pair(y, x)); for (ans = 0, tail = a.top().first; tail; tail--) { while (!a.empty()&&a.top().first >= tail)b.push(a.top().second), a.pop(); if (!b.empty())ans += b.top(), b.pop(); } printf("%d\n", ans); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator