Submission #679774

#TimeUsernameProblemLanguageResultExecution timeMemory
679774BeveritaTable Tennis (info1cup20_tabletennis)C++17
100 / 100
107 ms4580 KiB
#include <bits/stdc++.h> using namespace std; const int dimN = 15 * 1e4; const int dimK = 400; int v[1 + dimN + dimK], sol[1 + dimN]; int n, k; int check(int l,int r) { int ind = r - (n + l - 1); int sum = v[l] + v[r]; sol[1] = v[l]; sol[n] = v[r]; l++; r--; int val=1; while (l < r && ind >= 0){ if (v[l] + v[r] == sum){ val++; sol[val] = v[l]; sol[n - val + 1] = v[r]; l++; r--; } else if (v[l] + v[r] < sum){l++;ind--;} else{r--;ind--;} } return val; } int main() { cin >> n >> k; for (int i = 0; i < n + k; i++){cin >> v[i];} for (int i = 0; i < k + 1; i++){ bool verif = 0; for (int j = n + i - 1; j < n + k; j++){ int l=i,r=j; if (check(l,r) == n / 2){ verif = true; break; } } if (verif)break; } for (int i = 1; i <= n; i++){ cout << sol[i] << " "; } 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...