Submission #686611

#TimeUsernameProblemLanguageResultExecution timeMemory
686611alexdumitruTable Tennis (info1cup20_tabletennis)C++14
0 / 100
29 ms3104 KiB
#include <iostream> #include <vector> using namespace std; const int NMAX = 150000; int n, k; int a[NMAX + 401]; vector<int> v1, v2; bool works(int sum) { v1.clear(); v2.clear(); int cnt = 0; int i = 1; int j = n + k; while(cnt < n / 2 && (j - i + 1) / 2 + cnt >= n / 2) { if(a[i] + a[j] == sum) { cnt++; i++; j--; v1.push_back(a[i]); v2.push_back(a[j]); } else if(a[i] + a[j] < sum) i++; else j--; } return cnt == n / 2; } void solve() { cin >> n >> k; for(int i = 1; i <= n + k; i++) cin >> a[i]; bool ok = false; for(int i = 1; i <= k + 1 && ok == false; i++) for(int j = max(i + 1, n); j <= n + k && ok == false; j++) if(works(a[i] + a[j])) ok = true; for(int i = 0; i < n / 2; i++) cout << v1[i] << ' '; for(int i = n / 2 - 1; i >= 0; i--) cout << v2[i] << ' '; cout << '\n'; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); solve(); 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...