经典的双指针题
题目链接

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int v[maxn];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	sort(v,v+n);
	int i=0,j=n-1;
	
	while(i<j){
		if(v[i]+v[j]==m){
			cout<<v[i]<<" "<<v[j]<<endl;
			break;
		}else if(v[i] + v[j] > m){
			j--;
		}else i++;
	}
	if(i==j) cout<<"No Solution"<<endl;
	
	return 0;
}