fork download
  1. #include <bits/stdc++.h>
  2. #define FOR(i,a,b) for(int i=(a), _b=(b); i<=_b; ++i)
  3. #define fi first
  4. #define se second
  5. #define el "\n"
  6. #define pb push_back
  7. #define sz(a) (int)(a).size()
  8. #define FILL(a,x) memset(a,x,sizeof(a))
  9. using namespace std;
  10. typedef long long ll;
  11. typedef pair<int,int> ii;
  12. const int N = (int)1e6+3;
  13.  
  14. int main(){
  15. ios::sync_with_stdio(false);
  16. cin.tie(nullptr); cout.tie(nullptr);
  17. freopen("data.inp","r",stdin);
  18. freopen("data.out","w",stdout);
  19.  
  20. int n, x;
  21. cin >> n >> x;
  22. vector<int> a(n);
  23. FOR(i,0,n-1) cin >> a[i];
  24. sort(a.begin(), a.end());
  25.  
  26. int i = 0, j = n-1, ans = 0;
  27. while(i <= j){
  28. if(i < j && a[i] + a[j] <= x) { ++i; --j; }
  29. else --j;
  30. ++ans;
  31. }
  32. cout << ans;
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0.01s 5308KB
stdin
Standard input is empty
stdout
Standard output is empty