phunghieu5c
Rating
-
Bài tập
3
Điểm
1873
Rating #
-
Điểm #
15439
Giới thiệu
include <iostream>
include <math.h>
include <algorithm>
include <climits>
include <queue>
include <vector>
include <stack>
include <string>
include <iomanip>
include <tuple>
include <set>
include <map>
using namespace std;
define int long long
const int MAXN = 300005;
int a[MAXN];
int s;
int n;
void solve(){
cin >> n >> s;
for(int i = 1 ; i <= n ;i++){
cin >> a[i];
}
int i = 1;
int j = n ;
while(i <= j){
if(a[i] + a[j] < s){
i++;
}else if(a[i] + a[j] > s){
j--;
}else if(a[i]+a[j] == s){
cout << i << " " << j << endl;
return;
}
}
cout << "No solution" << endl;
return;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int t=1;
// cin >> t;
while(t--){
solve();
}
return 0;
}