Submission #753094

#TimeUsernameProblemLanguageResultExecution timeMemory
753094DJeniUpTable Tennis (info1cup20_tabletennis)C++17
87 / 100
3072 ms4428 KiB
#include "bits/stdc++.h" //#pragma GCC optimize("Ofast") //#pragma GCC optimize("O3") using namespace std; typedef int ll; typedef unsigned long long ull; typedef pair<ll,ll>pairll; typedef pair<ll,ull>pairull; typedef pair<ll,pairll>pair3l; typedef long double ld; typedef pair<ld,ll>pairld; #define fr first #define sc second #define pb push_back #define endl '\n' #define N 100007 //#define MOD 998244353 #define INF 100000000000007 #define eps 0.0000000001 ll n,k,d[2*N],s[2*N]; ll S(ll x){ ll res=0; for(int i=1;i<=n+k;i++){ s[i]=0; } ll l=1; ll r=n+k; while(l<r){ if(d[l]+d[r]<x)l++; else if(d[l]+d[r]>x)r--; else{ res+=2; s[l]=1; s[r]=1; l++; r--; } if(res==n)return 1; } return 0; } int main(){ cin>>n>>k; for(int i=1;i<=n+k;i++){ cin>>d[i]; } sort(d+1,d+1+n+k); ll fl=0; for(int i=1;i<=n+k;i++){ for(int j=n+k;j>i;j--){ if(j-i+1>=n){ if(S(d[i]+d[j])==1){ fl=1; break; } }else break; } if(fl==1)break; } //if(fl==0)exit(1); ll r=n; for(int i=1;i<=n+k;i++){ if(s[i]==1){ cout<<d[i]; r--; if(r!=0)cout<<" "; } } //if(r!=0)exit(1); //cout<<endl; 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...