# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
791084 | Andrey | Table Tennis (info1cup20_tabletennis) | C++14 | 176 ms | 4568 KiB |
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;
int n,k;
vector<int> ans(0);
vector<int> haha(0);
bool check(int a) {
ans.clear();
int l = 0,r = n+k-1;
while(l < r) {
if(r-l+1+ans.size() < n) {
return false;
}
while(r > l && haha[l]+haha[r] > a) {
r--;
}
if(r <= l) {
return false;
}
if(haha[r]+haha[l] == a) {
ans.push_back(haha[l]);
ans.push_back(haha[r]);
if(ans.size() == n) {
return true;
}
}
l++;
}
return false;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> k;
int a;
for(int i = 0; i < n+k; i++) {
cin >> a;
haha.push_back(a);
}
for(int i = 0; i < k+1; i++) {
for(int j = n+k-1; j >= n-1 && j > i; j--) {
if(check(haha[i]+haha[j])) {
sort(ans.begin(),ans.end());
for(int y = 0; y < n; y++) {
cout << ans[y] << " ";
}
cout << endl;
return 0;
}
}
}
return 0;
}
Compilation message (stderr)
# | 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... |