#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define endl '\n'
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
const int mod = 1e9 + 7;
const int N = 1e6 + 15;
const ll inf = 1e18;
int n,k;
vector<int> a;
int solve(int x){
int p1=0,p2=n-1;
int cur = 0;
while (p1<p2){
if (a[p1]+a[p2]==x){
cur+=2;
p1++;p2--;
}
else if (a[p1]+a[p2] < x){
p1++;
}
else if (a[p1]+a[p2] > x){
p2--;
}
}
return cur;
}
void print(int x){
int p1=0,p2=n-1;
vector<int> ans;
while (p1<p2){
if (a[p1]+a[p2]==x){
ans.pb(p1+1);
ans.pb(p2+1);
p1++;p2--;
}
else if (a[p1]+a[p2] < x){
p1++;
}
else if (a[p1]+a[p2] > x){
p2--;
}
}
sort(all(ans));
for (auto it :ans){
cout << it << ' ';
}
return;
}
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin >> n >> k;
int o = n;
n = n+k;
a.resize(n);
for (int i=0;i<n;i++){
cin >> a[i];
}
k = min(k+1,n/2 + 1);
int ans = -1;
for (int i=0;i<k;i++){
for (int j=0;j<k;j++){
if (solve(a[i]+a[n-1-j])==o){
ans = a[i]+a[n-1-j];
break;
}
}
if (ans!=-1) break;
}
print(ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output not subsequence of input |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
856 KB |
Output not subsequence of input |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
31 ms |
3740 KB |
Output not subsequence of input |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
212 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output not subsequence of input |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
93 ms |
212 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |