This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using pi = pair<int,int>;
#define ST first
#define ND second
#define PB push_back
const int nax = 150 * 1000 + 10 + 400;
int n, k;
int w[nax];
int main() {
//ios_base::sync_with_stdio(0);
//cin.tie(0);
cin >> n >> k;
for(int i = 1; i <= n + k; ++i) cin >> w[i];
for(int l = 0; l <= k; ++l) {
for(int r = 0; r + l <= k; ++r) {
int lt = k - (l + r);
int a = l + 1, b = n + k - r;
int sum = w[a] + w[b];
vi ans = {a, b};
bool ok = 1;
while(a + 1 < b) {
a++;
b--;
while(w[a] + w[b] != sum) {
if(w[a] + w[b] > sum) {
b--;
lt--;
if(lt < 0) {
ok = 0;
break;
}
} else {
a++;
lt--;
if(lt < 0) {
ok = 0;
break;
}
}
}
ans.PB(a);
ans.PB(b);
if(!ok) break;
}
if(ok) {
while(lt > 0) {
ans.pop_back();
ans.pop_back();
lt -= 2;
}
sort(ans.begin(), ans.end());
for(int x : ans) cout << x << " ";
return 0;
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |