标签:ring pac cstring 指针 include stream int stdio.h string
#include<iostream> #include<vector> #include<algorithm> #include<cstring> #include<map> #include<set> #include<cstring> #include<stdio.h> #include<queue> using namespace std; typedef pair<int,int> P; const int MAXN = 1e5+99; int sum[MAXN], val[MAXN]; vector<int> vec; vector<P> res; int N, M, MIN=1e9; int main() { int num; cin >> N >> M; for(int i = 0; i < N;i++) { cin >> num; vec.push_back(num); } sort(vec.begin(), vec.end()); int i = 0, j = N-1; while(i < j) { if(vec[i] + vec[j] == M) { cout << vec[i] << " " << vec[j]; return 0; }else if(vec[i] + vec[j] < M) { i++; }else { j--; } } cout << "No Solution"; }
双指针法的应用
标签:ring pac cstring 指针 include stream int stdio.h string
原文地址:https://www.cnblogs.com/dcklm/p/10350676.html