# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
675117 | uylulu | Table Tennis (info1cup20_tabletennis) | C++17 | 3068 ms | 25216 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
map<int,bool> mp;
vector<pair<int,int>> asd;
void build(int sum,int l,int r) {
mp.clear();
for(int i = l;i <= r;i++) {
mp[num[i]] = 1;
}
for(int i = l;i <= r;i++) {
if(sum < num[i]) continue;
mp[num[i]] = false;
if(mp[sum - num[i]]) {
asd.push_back({sum - num[i],num[i]});
}
}
if(asd.size() < n/2 - 1) {
asd.clear();
return;
}
vector<int> res;
for(int i = 0;i < n/2 - 1;i++) {
res.push_back(asd[i].first);
res.push_back(asd[i].second);
}
sort(res.begin(),res.end());
cout<<num[l - 1]<<" ";
for(auto u : res) {
cout<<u<<" ";
}
cout<<num[r + 1]<<endl;
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;
int len = n + k;
for(int i = 1;i <= len;i++) {
cin>>num[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 + 1,j - 1);
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |