#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
vector<int>v;
for(int i=0;i<n;i++)
{
int y;
cin>>y;
v.push_back(y);
}
int m;
cin>>m;
int b1,b2;
sort(v.begin(),v.end());
for(int i=0;i<v.size()-1;i++)
{
for(int j=i+1;j<v.size();j++)
{
if(v[i]+v[j]==m)
{
b1=v[i];
b2=v[j];
}
}
}
printf("Peter should buy books whose prices are %d and %d.\n\n", b1, b2);
}
return 0;
}
0 comments :
Post a Comment