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 <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <fstream>
#include <iterator>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <cctype>
#include <string>
#include <cassert>
#include <set>
#include <bitset>
#include <unordered_set>
#include <numeric>
using ll = int64_t;
#define pb push_back
#define all(a) a.begin(),a.end()
#define ppi pair<int,pair<int,int>>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//#define int int64_t
// xcode cant include bits/stdc++.h
using namespace std;
/* /\_/\
* (= ._.)
* / > \>
*/
// encouraging cat
//const int INF = 10000000000000000;
//const int mod = 1000000007;
const int mod = 998244353;
const int MAXN = 100005;
//ifstream fin("trenuri.in");
//ofstream fout("trenuri.out");
unordered_map<int,int> mp;
unordered_map<int,int> occ;
int32_t main() {
fast
int n,k;
cin >> n >> k;
vector<int> a(n + k);
for (int i = 0;i < n + k;i++)
{
cin >> a[i];
occ[a[i]]++;
}
int l = 0;
int p = 0;
for (l = 0;l < n + k;l++)
{
if (l > k)
p++;
for (int i = n + k - p - 1;i >= 0 && i >= n - l - 1 && i > l;i--)
{
mp[a[l] + a[i]]++;
}
//r++;
}
int res = -1;
for (auto it:mp)
{
if (it.second >= n / 2)
{
res = it.first;
break;
}
}
//cout << res << '\n';
//assert(res != -1);
int cnt = 0;
for (int i = 0;i < n + k;i++)
{
if (occ[res - a[i]] > 0)
{
cout << a[i] << " ";
cnt++;
}
if (cnt == n)
break;
}
cout << '\n';
return 0;
}
Compilation message (stderr)
tabletennis.cpp:31:9: warning: "/*" within comment [-Wcomment]
31 | /* /\_/\
|
# | 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... |