B题不用结构体的解法 #include<iostream> #include<string> #include<cstring> #include<vector> #include<map> #include<set> #include<queue> #include<cmath> #include<cstdio> #include<algorithm> #define int long long using namespace std; const int N = 1e6 + 5;  const int inf = 0x3f3f3f3f;//106110956 int a[N], b[N], c[N]; void solve() {     int x, n, m;     cin >> x >> n >> m;     int cnt = 0;     for(int i = 1; i <= n; i++){      cin >> a[i] >> b[i];      if(a[i] <= m){      c[cnt++] = b[i]; } }     sort(c, c + cnt);     int ans = x, res = 0;     for(int i = 0; i < cnt; i++){      int t = ans;      if(t - c[i] > 0){      res++; } ans -= c[i]; } cout << res << endl; } signed main() { ios::sync_with_stdio(0); cin.tie(0),cout.tie(0); int t = 1; //cin >> t; while(t--){ solve(); } return 0; }