# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
675183 | hotboy2703 | Table Tennis (info1cup20_tabletennis) | C++14 | 344 ms | 32384 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 a[151000];
int n,k;
bool check(int x){
int l = 1;
int r = n;
int cnt = 0;
while (l < r){
if (a[l] + a[r] > x){cnt++;r--;}
else if (a[l] + a[r] < x){l++;cnt++;}
else{l++;r--;}
if (cnt > k)return 0;
}
vector <int> ans;
l = 1;
r = n;
while (l < r){
if (a[l] + a[r] > x){r--;}
else if (a[l] + a[r] < x){l++;}
else{if (ans.size() < n - k){ans.push_back(a[l]);ans.push_back(a[r]);}l++;r--;}
}
sort(ans.begin(),ans.end());
for (auto y:ans)cout<<y<<' ';
cout<<'\n';
return 1;
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
cin>>n>>k;n += k;
for (int i = 1;i <= n;i ++){
cin>>a[i];
}
map <int,int> cnt;
for (int i = 1;i <= 2 * k && i <= n;i ++){
for (int j = max(1,n - 2 * k + 1);j <= n;j ++){
cnt[a[i] + a[j]]++;
}
}
for (auto x:cnt){
if (x.second >= k || x.second >= n - k){
if (check(x.first))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... |