大佬们 八十四分是为什么啊啊啊啊啊 code:
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int n, a[100010];
int cc;
int ans;
int main(){
int x, y;
int up = 0;
int down = 0;
cin >> n;
for(int i = 1; i <= n; i++){
cin >> x >> y;
up += x;
down += y;
a[i] = x - y;
}
cc = down - up;
sort(a + 1, a + n + 1);
if(cc == 0){
cout << 0;
return 0;
}
else if(cc < 0){
for(int i = n; i >= 1; i--){
if(a[i] > 0 && cc + 2 * a[i] <= 0){
cc += 2 * a[i];
ans ++;
}
}
}
else{
for(int i = 1; i <= n; i++){
if(a[i] < 0 && cc + 2 * a[i] >= 0){
cc += 2 * a[i];
ans ++;
}
}
}
cout << ans;
return 0;
}