forked from fineanmol/Hacktoberfest2024
-
Notifications
You must be signed in to change notification settings - Fork 30
/
cses_sortings3.cpp
64 lines (62 loc) · 1.36 KB
/
cses_sortings3.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimization ("unroll-loops")
#define ll long long
#define MAX_SIZE 1000005
#define sp " "
#define M 1000000000000000007
#define el endl
#define pb push_back
#define mp make_pair
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rop(i,a,n) for(int i=a;i<=n;i++)
#define vll vector<ll>
#define I insert
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) v.begin(),v.end()
#define PI 3.1415926535
#define fi first
#define se second
#define pp pair<int,int>
#define setx(n) fixed<<setprecision(n)
#define MAX (int)2e5+10
#include <string.h>
using namespace std;
/*..........................................................................*/
void time_limit_exceeded()
{
ll n,x; cin>>n>>x;
vll v(n);
rep(i,0,n) cin>>v[i];
sort(all(v));
ll cnt=0;
ll i=0,j=n-1;
while(i<j)
{
if(v[i]+v[j]<=x)
{
cnt++;
i++;
j--;
}
else
j--;
}
cnt+=(n-2*cnt);
cout<<cnt<<el;
}
/*..........................................................................*/
/*
--> Run sample testcases with diff. nums
*/
int main()
{
ll t=1;
// cin>>t;
while(t--)
{
time_limit_exceeded();
}
return 0;
}