제출 #674459

#제출 시각아이디문제언어결과실행 시간메모리
674459QwertyPiTable Tennis (info1cup20_tabletennis)C++14
100 / 100
2941 ms15152 KiB
#include <bits/stdc++.h> using namespace std; int n, k; int a[150401]; void gen(int x){ vector<int> Fr, Ba; int l = 0, r = n + k - 1; while(l < r){ if(a[l] + a[r] == x) { Fr.push_back(l); Ba.push_back(r); l++; r--; } else if(a[l] + a[r] > x) r--; else l++; } reverse(Ba.begin(), Ba.end()); for(auto i : Fr) cout << a[i] << ' '; for(auto i : Ba) cout << a[i] << ' '; } unordered_map<int, int> M; int main(){ cin.tie(0); cout.tie(0)->sync_with_stdio(false); cin >> n >> k; for(int i = 0; i < n + k; i++){ cin >> a[i]; } vector<int> v; for(int i = 0; i <= k; i++){ for(int j = max(i + 1, n + k - 1 - i - k); j <= min(n + k - 1, n + k - 1 - i + k); j++){ M[a[i] + a[j]]++; } } for(int i = k + 1; i < n + k; i++){ for(int j = max(i + 1, n + k - 1 - i - k); j <= min(n + k - 1, n + k - 1 - i + k); j++){ if(M.count(a[i] + a[j])) M[a[i] + a[j]]++; } } for(auto m : M){ if(m.second == n / 2){ gen(m.first); 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...