Submission #690754

#TimeUsernameProblemLanguageResultExecution timeMemory
690754andrei_iorgulescuTable Tennis (info1cup20_tabletennis)C++14
49 / 100
3007 ms2908 KiB
#include <bits/stdc++.h> #pragma GCC optimize("unroll-loops") using namespace std; ifstream in("tabletennis.in"); ofstream out("tabletennis.out"); int n,k,a[150500]; int sol[150005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> k; for (int i = 1; i <= n + k; i++) cin >> a[i]; sort(a + 1,a + n + k + 1); for (int i = 1; i <= k + 1; i++) { for (int j = n - 1; j <= n + k; j++) { int sum = a[i] + a[j]; int st = i + 1,dr = j - 1; int sz = 3; sol[1] = a[i]; sol[2] = a[j]; while (st < dr and sz <= n and sz + (dr - st + 1) - 1 <= n) { while (st < dr) { if (a[st] + a[dr] < sum) st++; else if (a[st] + a[dr] > sum) dr--; else break; } if (a[st] + a[dr] != sum) break; sol[sz++] = a[st++]; sol[sz++] = a[dr--]; } if (sz == n + 1) { sort(sol + 1,sol + n + 1); for (int j = 1; j <= n; j++) cout << sol[j] << ' '; 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...