제출 #640170

#제출 시각아이디문제언어결과실행 시간메모리
640170tvladm2009Table Tennis (info1cup20_tabletennis)C++14
100 / 100
59 ms4528 KiB
#include <bits/stdc++.h> using ll = long long; const int MAX_N = 15 * 1e4; const int MAX_K = 400; int a[1 + MAX_N + MAX_K], answer[1 + MAX_N]; int main() { std::ios_base::sync_with_stdio(0); std::cin.tie(0); int n, k; std::cin >> n >> k; for (int i = 0; i < n + k; i++) { std::cin >> a[i]; } for (int i = 0; i < k + 1; i++) { bool ok = false; for (int j = n + i - 1; j < n + k; j++) { int elim = j - (n + i - 1); int l = i, r = j; int sum = a[l] + a[r]; answer[1] = a[l]; answer[n] = a[r]; l++; r--; int m = 1; while (l < r && elim >= 0) { if (a[l] + a[r] == sum) { m++; answer[m] = a[l]; answer[n - m + 1] = a[r]; l++; r--; } else if (a[l] + a[r] < sum) { l++; elim--; } else { r--; elim--; } } if (m == n / 2) { ok = true; break; } } if (ok) { break; } } for (int i = 1; i <= n; i++) { std::cout << answer[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...