제출 #1123604

#제출 시각아이디문제언어결과실행 시간메모리
1123604epicci23Table Tennis (info1cup20_tabletennis)C++20
87 / 100
3095 ms4288 KiB
#include "bits/stdc++.h" #define int long long #define all(v) v.begin() , v.end() #define sz(a) (int)a.size() using namespace std; void _(){ int n,k; cin >> n >> k; int M = n + k; int ar[M+5]; for(int i=1;i<=M;i++) cin >> ar[i]; for(int l=1;l<=k+1;l++){ for(int r=M;r>=M-k;r--){ if(l-1+M-r>k || r-l+1 < n) continue; int p = r, val = ar[l] + ar[r]; vector<int> ans; for(int i = l; i <= r ; i++){ if(ar[i] > val / 2) continue; while(p > i && ar[i] + ar[p] > val) p--; if(p <= i) break; if(ar[i] + ar[p] == val && sz(ans) < n){ ans.push_back(ar[i]); ans.push_back(ar[p]); } } if(sz(ans) == n){ sort(all(ans)); for(int x:ans) cout << x << ' '; cout << '\n'; return; } } } } int32_t main(){ cin.tie(0); ios::sync_with_stdio(0); int tc=1;//cin >> tc; while(tc--) _(); 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...