제출 #914647

#제출 시각아이디문제언어결과실행 시간메모리
914647NValchanovTable Tennis (info1cup20_tabletennis)C++17
9 / 100
259 ms6372 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; 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...