Submission #921393

#TimeUsernameProblemLanguageResultExecution timeMemory
921393maxFedorchukTable Tennis (info1cup20_tabletennis)C++17
9 / 100
116 ms6096 KiB
#include "bits/stdc++.h" using namespace std; const long long MX=2e5+10; long long vis[MX]; long long a[MX]; long long n,k; void solve(long long sum,long long nm) { long long l=1,r=n+k,kpr=0,kg=0; while(l<r) { if((a[l]+a[r])<sum) { l++; kpr++; } if((a[l]+a[r])==sum) { vis[l]=vis[r]=nm; l++; r--; kg+=2; } if((a[l]+a[r])>sum) { r--; kpr++; } if(kpr>k) { return; } if(kg==n) { for(long long i=1;i<=n;i++) { if(vis[i]==nm) { cout<<a[i]<<" "; } } cout<<"\n"; exit(0); } } } int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin>>n>>k; for(long long i=1;i<=n+k;i++) { cin>>a[i]; } for(long long i=1,uk=1;i<=(k+1);i++,uk++) { for(long long j=max(n,i+1);j<=n+k;j++,uk++) { solve(a[i]+a[j],uk); } } 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...