Submission #860138

#TimeUsernameProblemLanguageResultExecution timeMemory
860138ThylOneTable Tennis (info1cup20_tabletennis)C++14
100 / 100
101 ms4940 KiB
//#################### //Binome_Equilibres //#################### #include<bits/stdc++.h> using namespace std; int n,k; vector<int> nums; bool possible(int start,int end,int K){ int target = nums[start]+nums[end]; vector<int> S,E; S.push_back(nums[start]); E.push_back(nums[end]); start++; end--; while(start<end && K>=0){ int sum = nums[start]+nums[end]; if(sum>target){ K--; end--; }else if(sum<target){ K--; start++; }else{ S.push_back(nums[start]); E.push_back(nums[end]); start++; end--; } } if(K<0)return false; while(n!=(int(S.size()+E.size()))){ S.erase(S.begin()); E.erase(E.begin()); } for(int v:S)cout<<v<<' '; reverse(E.begin(),E.end()); for(int v:E)cout<<v<<' '; cout<<'\n'; return true; } signed main(){ cin>>n>>k; nums.resize(n+k); for(int i=0;i<n+k;i++){ cin>>nums[i]; } for(int i=0;i<=k;i++){ int taked = i; for(int j=n+k-1;j>=0 && taked<=k;j--){ if(possible(i,j,k-taked)){ return 0; } taked++; } } 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...