# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
746688 | Abrar_Al_Samit | Table Tennis (info1cup20_tabletennis) | C++17 | 333 ms | 33824 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;
const int nax = 150402;
int a[nax];
int n, k;
void check(int sum) {
int l = 1, r = n+k;
vector<int>b;
int cur = a[1] + a[n+k];
while(l<r) {
if(cur>sum) {
cur -= a[r];
--r;
cur += a[r];
}
else if(cur<sum) {
cur -= a[l];
++l;
cur += a[l];
} else {
b.push_back(a[l]);
b.push_back(a[r]);
if(b.size()==n) {
sort(b.begin(), b.end());
for(int x : b) {
cout<<x<<' ';
}
cout<<'\n';
exit(0);
}
++l, --r;
cur = a[l] + a[r];
}
}
}
void PlayGround() {
cin>>n>>k;
for(int i=1; i<=n+k; ++i) {
cin>>a[i];
}
if(n+k < 4 * k) {
for(int i=1; i<=n+k; ++i) {
for(int j=i+1; j<=n+k; ++j) {
check(a[i]+a[j]);
}
}
} else {
map<int, int>cnt;
for(int i=1; i<=2*k; ++i) {
for(int j=n-k+1; j<=n+k; ++j) {
cnt[a[i]+a[j]]++;
}
}
for(auto [x, y] : cnt) {
if(y >= k) {
check(x);
}
}
}
// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
PlayGround();
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... |