Submission #675166

#TimeUsernameProblemLanguageResultExecution timeMemory
675166uyluluTable Tennis (info1cup20_tabletennis)C++17
100 / 100
213 ms15172 KiB
#include <bits/stdc++.h> using namespace std; #define ld long double #define int long long #define endl "\n" const int N = 3e5,K = 400; int num[N + 1],n,k,len; vector<pair<int,int>> res; map<int,int> mp; inline void build(int sum,int l,int r) { res.clear(); int curr = r - 1,lim = k - (l - 1 + len - r); for(int i = l + 1;i < curr;i++) { if(lim < 0) return; while(curr > i && num[i] + num[curr] > sum) { curr--; lim--; } if(num[i] + num[curr] == sum) { res.push_back({num[i],num[curr]}); curr--; } else { lim--; } if(lim < 0) return; } if((int)res.size() < n/2 - 1) { return; } vector<int> kq; for(int i = 0;i < n/2 - 1;i++) { kq.push_back(res[i].first); kq.push_back(res[i].second); } kq.push_back(num[l]); kq.push_back(num[r]); sort(kq.begin(),kq.end()); for(auto u : kq) { cout<<u<<" "; } exit(0); } signed main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); // freopen("in.txt","r",stdin); // freopen("out.txt","w",stdout); cin>>n>>k; len = n + k; for(int i = 1;i <= len;i++) { cin>>num[i]; mp[num[i]] = i; } for(int i = 1;i <= k + 1 && i <= len;i++) { int left = len - (k - i + 1); for(int j = left;j <= len;j++) { build(num[i] + num[j],i,j); } } 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...