제출 #675136

#제출 시각아이디문제언어결과실행 시간메모리
675136TranGiaHuy1508Table Tennis (info1cup20_tabletennis)C++17
15 / 100
423 ms489644 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; vector<int> s; void main_program(){ cin >> n >> k; v.resize(n + k); for (auto &i: v) cin >> i; s.resize(max(4 * k * k + 100, (n+k) * k * 2 + 100)); int crr = 0; int lim = n/2; if (n + k < 4 * k){ for (int i = 0; i < n+k; i++){ // X = (n+k-1) - j // i-k <= X <= i+k // i-k <= (n+k-1) - j <= i+k // j <= (n+k-1) + k - i // j >= (n+k-1) - k - i int lb = max(i+1, (n+k-1) - k - i), rb = min(n+k-1, (n+k-1) + k - i); for (int j = lb; j <= rb; j++){ // cout << ":: " << i << " " << j << "\n"; // mp[v[i] + v[j]]++; s[crr++] = v[i] + v[j]; } } } else{ lim = min(k, n/2); for (int i = 0; i < k * 2; i++){ for (int j = n+k - 1; j >= n-k; j--){ cout << ":: " << i << " " << j << "\n"; s[crr++] = v[i] + v[j]; } } } sort(s.begin(), s.begin() + crr); int ttcnt = 0; int prev = -1; int chk = false; for (int _i = 0; _i < crr; _i++){ if (s[_i] != prev){ prev = s[_i]; ttcnt = 0; chk = false; } if (s[_i] == prev) ttcnt++; if (ttcnt >= lim && !chk){ chk = true; set<int> tmp; for (auto i: v) tmp.insert(i); vector<int> res; for (auto i: tmp){ if (tmp.count(prev - i)) res.push_back(i); if ((int)res.size() >= n/2) break; } if ((int)res.size() < n/2) continue; for (int i = 0; i < n/2; i++) cout << res[i] << " "; for (int i = n/2 - 1; i >= 0; i--) cout << prev - 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...