Submission #311732

#TimeUsernameProblemLanguageResultExecution timeMemory
311732grtTable Tennis (info1cup20_tabletennis)C++17
100 / 100
194 ms4744 KiB
#include <bits/stdc++.h> using namespace std; using vi = vector<int>; using ll = long long; using pi = pair<int,int>; #define ST first #define ND second #define PB push_back const int nax = 150 * 1000 + 10 + 400; int n, k; int w[nax]; int main() { //ios_base::sync_with_stdio(0); //cin.tie(0); cin >> n >> k; for(int i = 1; i <= n + k; ++i) cin >> w[i]; for(int l = 0; l <= k; ++l) { for(int r = 0; r + l <= k; ++r) { int lt = k - (l + r); int a = l + 1, b = n + k - r; int sum = w[a] + w[b]; vi ans = {a, b}; bool ok = 1; while(a + 1 < b) { a++; b--; while(w[a] + w[b] != sum) { if(w[a] + w[b] > sum) { b--; lt--; if(lt < 0) { ok = 0; break; } } else { a++; lt--; if(lt < 0) { ok = 0; break; } } } ans.PB(a); ans.PB(b); if(!ok) break; } if(ok) { while(lt > 0) { ans.pop_back(); ans.pop_back(); lt -= 2; } sort(ans.begin(), ans.end()); for(int x : ans) cout << w[x] << " "; 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...