Submission #914649

#TimeUsernameProblemLanguageResultExecution timeMemory
914649NValchanovTable Tennis (info1cup20_tabletennis)C++17
100 / 100
258 ms6344 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; typedef long long ll; const ll MAXN=1e5+5e4+10; const ll MAXK=4e2+10; const ll MAXA=1e9+10; ll a[MAXN+MAXK],n,k,m; vector<ll>ans; void read() { cin>>n>>k; m=n+k; for(ll i=1;i<=m;i++) cin>>a[i]; } void print() { sort(ans.begin(), ans.end()); ll sz=ans.size(); for(ll i=0;i<sz;i++) { cout<<ans[i]<<" "; } cout<<endl; } void solve() { for(ll i=n/2;i<=n/2+k+1;i++) { ll cur=a[i]+a[i+1]; ll left=1,right=n+k; ll cnt=0; ans.clear(); while(left<right&&cnt<n/2) { ///cout<<"Lqwa granica : "<<left<<endl; while(left<right&&a[left]+a[right]>cur) { right--; ///cout<<"Dqsna granica : "<<right<<endl; } if(left<right&&a[left]+a[right]==cur) { ans.push_back(a[left]); ans.push_back(a[right]); ///cout<<"Nowo dobawqne na "<<left<<" i "<<right<<endl; cnt++; } left++; } if(cnt==n/2) { print(); return; } } } int main() { #ifdef ONLINE_JUDGE freopen(".in", "r", stdin); freopen(".out", "w", stdout); #endif ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); read(); solve(); 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...