Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int t;
- cin>>t;
- int a,b,sum,i,j;
- while(t--)
- {
- cin>>a>>b>>sum;
- int x[a],y[b];
- for(i=0;i<a;i++) cin>>x[i];
- for(i=0;i<b;i++) cin>>y[i];
- sort(x,x+a);
- sort(y,y+b);
- int count=0,c=0,d=1;
- for(i=0;i<a;i++)
- {
- for(j=0;j<b;j++)
- {
- if((x[i]+y[j])== sum)
- {
- count++;
- if(count>1)
- {
- cout<<", ";
- }
- cout<<x[i]<<" "<<y[j];
- }
- }
- }
- if(count==0) cout<<-1<<endl;
- cout<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement