# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
364055 | stefdasca | Table Tennis (info1cup20_tabletennis) | C++14 | 714 ms | 160016 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>
#define god dimasi5eks
#pragma GCC optimize("Ofast")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9
// #define fisier 1
using namespace std;
typedef long long ll;
int n, k, skills[200002];
unordered_map<int, int> frq;
bitset<2000000002>vv;
int main()
{
#ifdef fisier
ifstream f("input.in");
ofstream g("output.out");
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> k;
for(int i = 1; i <= n+k; ++i)
cin >> skills[i];
int smm = 0;
for(int i = 1; i <= k+1; ++i)
for(int j = n - (i-1); j <= min(n+k, n+k+k - (i-1)); ++j)
{
if(i >= j)
continue;
frq[skills[i] + skills[j]]++;
vv[skills[i] + skills[j]] = 1;
if(frq[skills[i] + skills[j]] == n/2)
{
smm = skills[i] + skills[j];
break;
}
}
for(int i = k+2; i <= min(20000, n/2+k); ++i)
if(!smm)
for(int j = n - (i-1); j <= min(n+k, n+k+k - (i-1)); ++j)
{
if(i >= j)
continue;
if(vv[skills[i] + skills[j]])
{
if(frq[skills[i] + skills[j]] + (n/2+k) - i + 1 < n/2)
vv[skills[i] + skills[j]] = 0;
else
{
++frq[skills[i] + skills[j]];
if(frq[skills[i] + skills[j]] == n/2)
{
smm = skills[i] + skills[j];
break;
}
}
}
}
if(!smm)
{
unordered_map<int, int> ::iterator it;
for(it = frq.begin(); it != frq.end(); ++it)
if(smm == 0)
smm = it -> first;
else
if(it -> second > frq[smm])
smm = it -> first;
}
int Rp = n+k;
vector<int> ans;
for(int i = 1; i <= n+k; ++i)
{
while(Rp > 0 && skills[i] + skills[Rp] > smm)
--Rp;
if(Rp > i && skills[i] + skills[Rp] == smm)
{
ans.pb(skills[Rp]);
ans.pb(skills[i]);
--Rp;
}
if(ans.size() == n)
break;
}
sort(ans.begin(), ans.end());
for(int i = 0; i < ans.size(); ++i)
cout << ans[i] << " ";
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... |