Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
- int main()
- {
- test
- {
- ll a[100005],c,d,e=0,f,i,j,k,l;
- cin>>c>>d;
- for(i=0;i<c;i++)
- {
- cin>>a[i];
- }
- sort(a,a+c);
- i=0;
- j=c-1;
- while(i<j && i<c && j>=0)
- {
- if((a[i]+a[j])==d)
- {
- e++;
- i++;
- j--;
- }
- else if((a[i]+a[j])<d)
- {
- i+=1;
- }
- else if((a[i]+a[j])>d)
- {
- j-=1;
- }
- }
- cout<<"Case #"<<cs<<": "<<e<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement