제출 #525128

#제출 시각아이디문제언어결과실행 시간메모리
525128Ahmed57Table Tennis (info1cup20_tabletennis)C++14
87 / 100
3070 ms5456 KiB
#include<bits/stdc++.h> using namespace std; vector<int>ans; int rec(int l,int r,int arr[],int sum,int k){ int p = 0; vector<int> v; while(l<=r){ if(arr[l]+arr[r]>sum){ r--; p++; }else if(arr[l]+arr[r]<sum){ l++; p++; }else{ v.push_back(arr[l]); v.push_back(arr[r]); l++; r--; } } if(p==k){ ans = v; return 1; }else{ return 0; } } int main(){ long long n,k; cin>>n>>k; int arr[n+k]; for(int i = 0;i<n+k;i++)cin>>arr[i]; sort(arr,arr+n+k); for(int i = 0;i<=k;i++){ for(int j = (n+k)-1;j>i;j--){ if(i+(((n+k)-1)-j)<=k){ //cout<<i<<" "<<j<<"\n"; int q = rec(0,(n+k)-1,arr,arr[i]+arr[j],k); if(q){ sort(ans.begin(),ans.end()); for(auto h:ans){ cout<<h<<" "; } return 0; } } } } 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...