#include<bits/stdc++.h> using namespace std ; #define ll long long int main() { const int mxN = 2e5; int n , m , a[mxN]; cin>>n>>m; for(int i =0;i<n;i++) { cin>>a[i]; } sort(a,a+n); int ans = 1; int i =0 ; int j = n-1; while(i<j) { if(a[i]+a[j]<m) { ans = ans+1; i++; } else { i++; j--; ans = ans+1; } } cout<<ans; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter