Submission #675082

#TimeUsernameProblemLanguageResultExecution timeMemory
675082hotboy2703Table Tennis (info1cup20_tabletennis)C++14
87 / 100
88 ms3336 KiB
#include<bits/stdc++.h> using namespace std; int a[150100]; 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; } 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]; } sort(a+1,a+1+n); vector <int> all; for (int i = 0;i <= k;i ++){ for (int j = 0;j <= i;j ++){ int l = j + 1; int r = n - (i - j); all.push_back(a[l] + a[r]); } } sort(all.begin(),all.end()); all.resize(unique(all.begin(),all.end())-all.begin()); for (auto x:all){ if (check(x)){ int l = 1; int r = n; vector <int> ans; while (l < r){ if (a[l] + a[r] > x){r--;} else if (a[l] + a[r] < x){l++;} else {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 0; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...