Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;typedef long double lf;typedef double fl;typedef string str;
- typedef vector<int> vi;typedef vector<vector<int>> vvi;typedef vector<fl> vf;typedef vector<ll> vl;
- typedef vector<lf> vlf;typedef vector<char> vc;typedef vector<str> vs;typedef pair<int,int> ii;
- # define f(i,a,b,c) for(ll i=a;i<b;i+=c)
- # define fd(i,a,b,c) for(ll i=a;i>=b;i-=c)
- # define ctoi(a) (a-'0')
- int ns[100000], n, x, i=0, j;
- void au(){
- j = n-1;
- while(i<j){
- if(ns[i]+ns[j] == x){
- cout<<ns[i]<<' '<<ns[j]<<'\n';
- return;
- }
- else if(ns[i]+ns[j]<x)++i;
- else --j;
- }
- }
- int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.precision(2);cout.setf(ios::fixed);
- cin>>n;
- f(i,0,n,1)cin>>ns[i];
- cin>>x, au();
- }
RAW Paste Data
Copied