Submission #675070

#TimeUsernameProblemLanguageResultExecution timeMemory
675070TranGiaHuy1508Table Tennis (info1cup20_tabletennis)C++17
9 / 100
3093 ms101584 KiB
#include <bits/stdc++.h> using namespace std; void main_program(); signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); main_program(); } int n, k; vector<int> v; map<int, int> mp; void main_program(){ cin >> n >> k; v.resize(n + k); for (auto &i: v) cin >> i; for (int i = 0; i < n; i++){ // X = (n-1) - j // i-k <= X <= i+k // i-k <= (n-1) - j <= i+k // j <= (n-1) + k - i // j >= (n-1) - k - i for (int j = max(i+1, n-1 - k - i); j <= min(n-1, n-1 + k - i); j++){ // cout << ":: " << i << " " << j << "\n"; mp[v[i] + v[j]]++; } } for (auto [key, value]: mp){ if (value < n/2) continue; set<int> tmp; for (auto i: v) tmp.insert(i); vector<int> res; for (auto i: tmp){ if (tmp.count(key - i)) res.push_back(i); if ((int)res.size() >= n/2) break; } for (int i = 0; i < n/2; i++) cout << res[i] << " "; for (int i = n/2 - 1; i >= 0; i--) cout << key - res[i] << " "; cout << "\n"; return; } }
#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...