Submission #362085

#TimeUsernameProblemLanguageResultExecution timeMemory
362085mosiashvililukaTable Tennis (info1cup20_tabletennis)C++14
87 / 100
3067 ms5868 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; long long nicerand(long long q){ long long qw=0,we=1; while(q>0){ long long ba=rand()%2; if(ba==1){ qw+=we; } we*=2;q--; } return qw; } 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); cin>>n>>k; a=n+k; for(i=1; i<=a; i++){ cin>>f[i]; } sort(f+1,f+a+1); if(a<k*3/2||1==1){ for(int hi=1; hi<=k+1; hi++){ for(int hj=a; hj>=a-k; hj--){ if(hi>=hj||hi-1+a-hj>k) continue; chk(f[hi]+f[hj]); } } }else{ while(1){ c=nicerand(21);d=nicerand(21); c=c%a+1;d=d%a+1; if(c==d) continue; if(m[f[c]+f[d]]!=0) continue; m[f[c]+f[d]]=1; chk(f[c]+f[d]); } } 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...