Submission #865921

#TimeUsernameProblemLanguageResultExecution timeMemory
865921Darren0724Table Tennis (info1cup20_tabletennis)C++17
100 / 100
127 ms5992 KiB
#include<bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") #pragma GCC target("avx2") mt19937 rnd(time(0)); int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n,k;cin>>n>>k; vector<int> v(n+k); for(int i=0;i<n+k;i++){ cin>>v[i]; } int flag=0; unordered_set<int> s; auto check=[&](int p)->void { if(s.count(p)){ return; } s.insert(p); int j=n+k-1; int cnt=0; vector<int> ans; int no=0; for(int i=0;i<n+k;i++){ while(i<j&&v[i]+v[j]>p){ no++; j--; } if(i>=j){ break; } if(i<j&&v[i]+v[j]==p){ ans.push_back(v[i]); ans.push_back(v[j]); cnt+=2; j--; } else{ no++; } if(no>k){ return; } } //cout<<ans.size()<<endl; if(cnt>=n){ sort(ans.begin(),ans.begin()+n); for(int i=0;i<n;i++){ cout<<ans[i]<<' '; } cout<<endl; flag=1; } }; while(!flag){ int i=rnd()%(k+1); int j=n-1+rnd()%(k+1); check(v[i]+v[j]); } 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...