Submission #365817

#TimeUsernameProblemLanguageResultExecution timeMemory
365817sobaTable Tennis (info1cup20_tabletennis)C++14
11 / 100
3095 ms4684 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; bool solve(vector<ll>v) { int l = 0 , r=v.size()-1; if(v[l]==-1) l++; if(v[r]==-1) r--; ll newmid, mid=(v[l]+v[r])/2; l++; r--; while(l<r) { if(v[l]==-1) l++; if(v[r]==-1) r--; newmid=(v[l]+v[r])>>1; l++; r--; if(mid!=newmid) return false; } return true; } int main() { ll n , k ; cin >> n >> k; //cout << n << " " << k << "\n"; vector<ll>v; ll x , y; for(int i = 0 ; i < n+k ; i++) { cin>> x; v.push_back(x*2); } if(k==1) { for(int i = 0 ; i < n+k ; i++) { x=v[i]; v[i]=-1; if(solve(v)) { //cout << "yes\n"; break; } else v[i]=x; //cout << "no\n"; } for(int i = 0 ; i < n+k ; i++) { if(v[i]!=-1) { cout << v[i]/2 << " "; } } return 0; } if(k==2) { for(int i = 0 ; i < n+k ; i++) { for(int j = i+1 ; j < n+k ; j++) { x=v[i]; v[i]=-1; y=v[j]; v[j]=-1; if(solve(v)) { break; } else { v[i]=x; v[j]=y; } } } for(int i = 0 ; i < n+k ; i++) { if(v[i]!=-1) { cout << v[i]/2 << " "; } } 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...