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