| ||||||||||
| 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 | |||||||||
一A#include <cstdio>
#include <queue>
#include <algorithm>
#define MAX_N 2600
using namespace std;
typedef pair<int,int> P;
P cow[MAX_N],bottle[MAX_N];
priority_queue<int,vector<int>,greater<int> > que;
int C,L,cur,result;
int main(){
scanf("%d%d",&C,&L);
for(int i = 0;i < C;++i){
scanf("%d%d",&cow[i].first,&cow[i].second);
}
for(int i = 0;i < L;++i){
scanf("%d%d",&bottle[i].first,&bottle[i].second);
}
sort(cow,cow + C);sort(bottle,bottle + L);
for(int i = 0;i < L;++i){
while(cur < C && cow[cur].first <= bottle[i].first){
que.push(cow[cur].second);
++cur;
}
while(!que.empty() && bottle[i].second){
int maxSPF = que.top();que.pop();
if(maxSPF >= bottle[i].first){
++result;
--bottle[i].second;
}
}
}
printf("%d\n",result);
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator