SHARE
TWEET


Untitled




Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- sort(a, a + n);
- int ans = 0, j = 0;
- for(int i = 0; i < n; i++)
- {
- while(a[j] - a[i] < k) j++;
- if(j >= n) break;
- ans += n - j;
- }
- cout << ans;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.