排序时不能按照城市人口的总人数(T进行演讲后,该城市支持T的人增加,同时支持A的人减少)
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PLL;
const int N = 200010;
PLL p[N];
int main() {
LL n;
cin >> n;
LL A = 0, T = 0;
for (int i = 0; i < n; i ++) {
LL a, b;
cin >> a >> b;
A += a;
p[i] = {a * 2 + b, a};
}
sort(p, p + n, greater<PLL>());
for (int i = 0; i < n; i ++) {
A -= p[i].second;
T += p[i].first - p[i].second;
if (T > A) {
cout << i + 1;
return 0;
}
}
return 0;
}