제출 #362102

#제출 시각아이디문제언어결과실행 시간메모리
362102mosiashvililukaTable Tennis (info1cup20_tabletennis)C++14
100 / 100
444 ms44780 KiB
#include<bits/stdc++.h> using namespace std; long long a,b,c,d,e,i,j,ii,jj,zx,xc,f[150409],k,n,pi,p[150409]; map <long long, long long> m; map <long long, long long>::iterator it; void chk(int q){ pi=0; ii=a; for(i=1; i<=a; i++){ while(ii>i&&f[ii]+f[i]>q) ii--; if(ii<=i) break; if(f[i]+f[ii]==q){ pi++; p[pi]=f[i]; pi++; p[pi]=f[ii]; } } if(pi>=n){ while(pi>n) pi-=2; sort(p+1,p+pi+1); for(i=1; i<=pi; i++){ cout<<p[i]<<" "; } exit(0); } } int main(){ ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0); //freopen("magalitiinput.txt","r",stdin); cin>>n>>k; a=n+k; for(i=1; i<=a; i++){ cin>>f[i]; } sort(f+1,f+a+1); if(4*k>=a){ for(int hi=1; hi<=k+1; hi++){ for(int hj=a; hj>=a-k; hj--){ if(hi>=hj||hi-1+a-hj>k||m[f[hi]+f[hj]]==1) continue; m[f[hi]+f[hj]]=1; chk(f[hi]+f[hj]); } } }else{ for(int hi=1; hi<=2*k; hi++){ for(int hj=a; hj>a-2*k; hj--){ m[f[hi]+f[hj]]++; } } for(it=m.begin(); it!=m.end(); it++){ if((*it).second>=k){ chk((*it).first); } } } 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...