Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- long long n, k, a[100005];
- int main()
- {
- cin >> n >> k;
- for(int i = 0; i < n; i++) cin >> a[i];
- sort(a, a + n);
- long long cnt = 0;
- for(int i = 0; i < n; i++)
- {
- int t = lower_bound(a, a + n, k - a[i]) - a - 1;
- if(t < i) break;
- else cnt += t - i;
- }
- cout << cnt;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement