제출 #686602

#제출 시각아이디문제언어결과실행 시간메모리
686602alexdumitruTable Tennis (info1cup20_tabletennis)C++14
87 / 100
3091 ms3220 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 j = n + k; for(int i = 1; i <= n + k; i++) { for(; j >= 1 && a[i] + a[j] > sum; j--); if(i >= j) break; if(a[i] + a[j] == sum) { cnt++; v1.push_back(a[i]); v2.push_back(a[j]); if(cnt == n / 2) break; } } 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...