제출 #1104767

#제출 시각아이디문제언어결과실행 시간메모리
1104767abushbandit_Table Tennis (info1cup20_tabletennis)C++17
87 / 100
3081 ms11600 KiB
#pragma GCC target("avx,avx2,fma") #pragma GCC optimize("Ofast,unroll-loops") #include "bits/stdc++.h" using namespace std; //~ #ifndef ONLINE_JUDGE //~ #include "debug.h" //~ #else //~ #define debug(...) //~ #define debugArr(...) //~ #endif #define int long long #define all(x) x.begin(),x.end() #define ff first #define ss second #define pb push_back template<class T, class U> inline bool chmin(T& a, const U& b) { if (a > b) { a = b; return true; } return false; } template<class T, class U> inline bool chmax(T& a, const U& b) { if (a < b) { a = b; return true; } return false; } const int inf = 1e9; const int mod = 1e9 + 7; const int N = 1e5 + 5; void solve() { int n,k; cin >> n >> k; int m = n; n += k; int a[n + 1]; for(int i = 1;i <= n;i++) cin >> a[i]; sort(a + 1,a + n + 1); for(int l = 1;l <= k + 1;l++) { int rem = (k + 1) - l; for(int r = n;r >= n - rem;r--) { if(r - l + 1 < m) { continue; } int cnt = 0; int nl = l,nr = r; int sum = a[r] + a[l]; while(l < r) { if(a[r] + a[l] == sum) { r--; l++; cnt += 2; } else if(a[r] + a[l] > sum) { r--; } else { l++; } } l = nl,r = nr; if(cnt == m) { set<int> ans; while(l < r) { if(a[r] + a[l] == sum) { ans.insert(a[r]); ans.insert(a[l]); r--; l++; } else if(a[r] + a[l] > sum) { r--; } else { l++; } } for(auto i : ans) cout << i << " "; return; } } } } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr); int t = 1; //~ cin >> t; while(t--) { solve(); } }
#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...