Submission #328946

#TimeUsernameProblemLanguageResultExecution timeMemory
328946ThaiBaHungTable Tennis (info1cup20_tabletennis)C++14
87 / 100
3078 ms4632 KiB
#include <bits/stdc++.h> using namespace std; const int N = 160003; const int K = 403; int n, k; int a[N]; void solve(int lo, int hi, int sum) { vector < int > res; int cur = 1; res.push_back(a[lo]), res.push_back(a[hi]); int i = lo + 1, j = hi - 1; while (i < j) { if (a[i] + a[j] > sum) j--; if (a[i] + a[j] < sum) i++; if (a[i] + a[j] == sum) { cur++; res.push_back(a[i]); res.push_back(a[j]); i++; j--; } } if (cur == n / 2) { sort(res.begin(), res.end()); for (int u : res) cout << u << " "; exit(0); } return; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k; int m = n + k; for (int i = 1; i <= m; i++) cin >> a[i]; sort(a + 1, a + m + 1); for (int i = 1; i <= k + 1; i++) { for (int j = i + n - 1; j <= m; j++) { solve(i, j, a[i] + a[j]); } } }
#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...