显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1000010;
ll n,a,b,t[N],ans;
map<ll,ll>mp;
int main () {
freopen("Compatible.in","r",stdin);
freopen("Compatible.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
cin >> n >> a >> b;
for (int i=1;i<=n;i++) {
int x,y;
cin >> x >> y;
t[i]=y;
mp[y]=x;
}
//cout << mp.count(1) <<' '<< mp.count(6) <<endl;
sort(t+1,t+1+n);
int mn;
for (int i=1;i<=n;i++) {
if (t[i]>b) continue;
if (mp.count(a-t[i])==1) {
mn=min(mp[t[i]],mp[a-t[i]]);
if (t[i]==a-t[i]) mn/=2;
mp[t[i]]-=mn;
mp[a-t[i]]-=mn;
ans+=mn;
//cout << t[i] <<' '<< mp[t[i]] <<' '<< mn <<' '<< 1 <<endl;
}
if (mp.count(b-t[i])==1) {
mn=min(mp[t[i]],mp[b-t[i]]);
if (t[i]==a-t[i]) mn/=2;
mp[t[i]]-=mn;
mp[b-t[i]]-=mn;
ans+=mn;
//cout << t[i] <<' '<< mp[t[i]] <<' '<< mn <<' '<< 2 <<endl;
}
}
cout << ans <<endl;
return 0;
}