ZJ b231: TOI2009 第三題:書


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define AC ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

int main()
{
AC
ll n,r=0,t=0;
cin>>n;
priority_queue<pair<ll,ll>> pq;
for(ll i=0;i<n;i++)
{
ll t1,t2;
cin>>t1>>t2;
pq.push({t2,t1});
}
for(;pq.size();pq.pop())
{
t+=pq.top().second;
r=max(r,t+pq.top().first);
}
cout<<r<<'\n';
}

留言

這個網誌中的熱門文章

TIOJ 1080 . A.逆序數對 (BIT解法)

ZJ d718: Waiting In Line

AtCoder Educational DP Contest E - Knapsack 2