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 ll long long
#define pb push_back
#define F first
#define S second
using namespace std;
const int N=2e5+5;
int n,k;
bool f[N];
double a[N];
vector < int > ans;
map < int , int > mp;
unordered_map < int , int > F;
void check(int x) {
ans.clear();
int r=n+k;
F.clear();
for (int i=1; i<=n+k; i++)
F[a[i]]++;
for (int i=1; i<=n+k; i++) {
if (x-a[i]<0) continue;
if (!F[a[i]]) continue;
--F[a[i]];
if (!F[x-a[i]]) { F[a[i]]++; continue; }
--F[x-a[i]];
ans.pb(a[i]),ans.pb(x-a[i]);
if (ans.size()==n) break;
}
if (ans.size()==n) {
sort(ans.begin(),ans.end());
for (int i=0; i<ans.size(); i++)
cout<<ans[i]<<" ";
exit(0);
}
}
main() {
ios::sync_with_stdio(false);
cin.tie(NULL),cout.tie(NULL);
cin>>n>>k;
for (int i=1; i<=n+k; i++)
cin>>a[i];
int R=min(4*k,n+k),L=max(1,n+k-4*k+1);
for (int i=1; i<=R; i++)
for (int j=L; j<=n+k; j++)
mp[a[i]+a[j]]++;
for (map < int , int > :: iterator it=mp.begin(); it!=mp.end(); ++it)
if ((it->second)>=k) check((it->first));
cout<<1/0<<"\n";
}
Compilation message (stderr)
tabletennis.cpp: In function 'void check(int)':
tabletennis.cpp:34:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
34 | if (ans.size()==n) break;
| ~~~~~~~~~~^~~
tabletennis.cpp:37:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
37 | if (ans.size()==n) {
| ~~~~~~~~~~^~~
tabletennis.cpp:39:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for (int i=0; i<ans.size(); i++)
| ~^~~~~~~~~~~
tabletennis.cpp:21:7: warning: unused variable 'r' [-Wunused-variable]
21 | int r=n+k;
| ^
tabletennis.cpp: At global scope:
tabletennis.cpp:45:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
45 | main() {
| ^
tabletennis.cpp: In function 'int main()':
tabletennis.cpp:61:10: warning: division by zero [-Wdiv-by-zero]
61 | cout<<1/0<<"\n";
| ~^~
# | 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... |