Submission #1028142

#TimeUsernameProblemLanguageResultExecution timeMemory
1028142DangerNoodle7591Table Tennis (info1cup20_tabletennis)C++17
100 / 100
1164 ms7344 KiB
#include<bits/stdc++.h> using namespace std; #define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define ll long long #define int long long int //#define endl '\n' #define N 2100 #define M 30 #define big 2147483647 #define bigg 9223372036854775807 #define pb push_back #define p push #define ins insert #define f first #define s second signed main(){ lalala; int n,k;cin>>n>>k; int arr[n+k]; vector<int> v,cev; for(int i=0;i<n+k;i++){ cin>>arr[i]; v.pb(arr[i]); } int fark=0; for(int i=0;i<=k;i++){ for(int j=1;j<=k+1;j++){ int yer=n+k-j; if(i==yer||i+j-1>k)break; int yes=0; int top=(arr[i]+arr[yer]); int kac=2; if(kac==n){ fark=top;break; } int skip=i+j-1; for(int m=i+1;m<yer;m++){ if(arr[m]>=top)break; int hedef=upper_bound(v.begin(),v.end(),(top-arr[m]))-v.begin(); hedef--; if(skip>k)break; //if(j==4)cout<<top<<" "<<arr[m]<<" "<<v[hedef]<<endl; if(m>=hedef)break; if(top-arr[m]!=v[hedef]){ skip++; continue; } kac+=2; if(kac==n){ yes=1;break; } } if(yes){ fark=top;//break; } } if(fark!=0)break; } for(int m=0;m<n+k;m++){ int hedef=upper_bound(v.begin(),v.end(),fark-arr[m])-v.begin(); hedef--; if(m>=hedef)break; if(fark-arr[m]!=v[hedef]){ continue; } //kac+=2; cev.pb(m+1); cev.pb(hedef+1); if((int)cev.size()==n)break; } sort(cev.begin(),cev.end()); for(auto u:cev)cout<<arr[u-1]<<" "; cout<<endl; }
#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...