-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSum of Two Values
128 lines (106 loc) · 1.87 KB
/
Sum of Two Values
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include <bits/stdc++.h>
#define ll long long
#define Mohamed cout<<"YES"<<endl;
#define Awad cout<<"NO"<<endl;
#define active_ctr int ctr=0;
#define test int t=0;cin>>t;while(t--)
#define Done return 0;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define clr(v, d) memset(v, d, sizeof(v))
#define endl "\n"
const int S = 1e6 + 5;
using namespace std;
vector<ll> prefix(int n , vector<int> a)
{
ll sum=a[0];
vector<ll>pre(n);
pre[0]=a[0];
for(int i=1;i<n;i++)
{
pre[i] =a[i]+sum;
sum=pre[i];
}
return pre;
}
void down(string &s)
{
transform(s.begin(),s.end(),s.begin(),:: tolower);
}
void up(string &s)
{
transform(s.begin(),s.end(),s.begin(),::toupper);
}
string convert_to_binary(int Decimal_Number)
{
string s;
while(Decimal_Number)
{
if(Decimal_Number%2!=0)
{
s.push_back('1');
}
else
{
s.push_back('0');
}
Decimal_Number/=2;
}
reverse(s.begin(),s.end());
return s;
}
int bitwise_xor(int NumberOne,int NumberTwo)
{
return NumberOne^NumberTwo;
}
int binary(int n,int x,vector<int>a) {
a.resize(S,0);
int l = 0, r = n-1;
int ans = -1;
while (l <= r) //{1,2,3,4,5,6,7}
{
ll mid = (l + r) / 2;
if (x == a[mid])
{
ans = mid;
r=mid-1;
}
else if (a[mid] < x) {
l = mid + 1;
} else {
r = mid - 1;
}
}
a.clear();
return ans;
}
bool can(ll mid ) {
}
int freq[S];
void solve() {
int n,target;
cin >> n >> target;
vector<pair<int,int>>a(n);
for(int i=0;i<n;i++)
{
cin>>a[i].first;
a[i].second=i+1;
}
sort(a.begin(),a.end());
for(int i=0,j=n-1;i<j;)
{
if(a[i].first+a[j].first==target)
{
cout << a[j].second << " " << a[i].second << endl;
return;
}
if(a[i].first+a[j].first<target)i++;
else if(a[i].first+a[j].first>target)j--;
}
cout<< -1 << endl;
}
int main()
{
fast
solve();
return 0;
}