#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;
double a[N];
vector < int > ans;
map < int , int > mp;
void check(double x) {
ans.clear();
int r=n+k;
for (int l=1; l<r && a[l]<=x; l++) {
while (x-a[l]<a[r]-x)
--r;
if (l<r && x-a[l]==a[r]-x)
ans.pb(a[l]),ans.pb(a[r]),--r;
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];
if (n<=4*k) {
for (int i=1; i<=n+k; i++)
for (int j=i+1; j<=n+k; j++)
mp[a[i]+a[j]]++;
for (map < int , int > :: iterator it=mp.begin(); it!=mp.end(); ++it)
check((it->first)/2.0);
cout<<1/0<<"\n";
exit(0);
}
int R=min(2*k,n+k),L=max(1,n-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)/2.0);
}
Compilation message
tabletennis.cpp: In function 'void check(double)':
tabletennis.cpp:27:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
27 | if (ans.size()==n) break;
| ~~~~~~~~~~^~~
tabletennis.cpp:30:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
30 | if (ans.size()==n) {
| ~~~~~~~~~~^~~
tabletennis.cpp:32:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for (int i=0; i<ans.size(); i++)
| ~^~~~~~~~~~~
tabletennis.cpp: At global scope:
tabletennis.cpp:38:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
38 | main() {
| ^
tabletennis.cpp: In function 'int main()':
tabletennis.cpp:52:12: warning: division by zero [-Wdiv-by-zero]
52 | cout<<1/0<<"\n";
| ~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
896 KB |
Output is correct |
2 |
Correct |
87 ms |
3800 KB |
Output is correct |
3 |
Correct |
70 ms |
3696 KB |
Output is correct |
4 |
Correct |
72 ms |
3824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
3824 KB |
Output is correct |
2 |
Correct |
70 ms |
3692 KB |
Output is correct |
3 |
Correct |
73 ms |
3916 KB |
Output is correct |
4 |
Correct |
71 ms |
3696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
768 KB |
Output is correct |
2 |
Correct |
11 ms |
1024 KB |
Output is correct |
3 |
Correct |
4 ms |
1024 KB |
Output is correct |
4 |
Correct |
6 ms |
1024 KB |
Output is correct |
5 |
Correct |
4 ms |
1024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
70 ms |
3820 KB |
Output is correct |
3 |
Correct |
72 ms |
3820 KB |
Output is correct |
4 |
Correct |
73 ms |
3692 KB |
Output is correct |
5 |
Correct |
74 ms |
3696 KB |
Output is correct |
6 |
Correct |
77 ms |
3820 KB |
Output is correct |
7 |
Correct |
75 ms |
3824 KB |
Output is correct |
8 |
Correct |
75 ms |
3700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
4608 KB |
Output is correct |
2 |
Correct |
423 ms |
31336 KB |
Output is correct |
3 |
Correct |
370 ms |
33004 KB |
Output is correct |
4 |
Correct |
266 ms |
29040 KB |
Output is correct |
5 |
Correct |
217 ms |
10744 KB |
Output is correct |
6 |
Correct |
107 ms |
5488 KB |
Output is correct |
7 |
Correct |
254 ms |
27120 KB |
Output is correct |
8 |
Correct |
246 ms |
29548 KB |
Output is correct |