# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
957094 | MuntherCarrot | Table Tennis (info1cup20_tabletennis) | C++14 | 203 ms | 33996 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;
#define ll long long
#define endl '\n'
#define all(x) x.begin(),x.end()
const int MOD = 1e9 + 7, SZ = 1e5 + 10, MX = 1e9;
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, k;
cin >> n >> k;
int arr[n + k];
for(int &i : arr)
cin >> i;
map<int, int> frq;
vector<int> vec;
if(k*4 >= n + k){
for(int i=0;i<n+k;i++){
for(int j=i+1;j<n+k;j++)
vec.push_back(arr[i] + arr[j]);
}
}
else{
for(int i=0;i<=k*2;i++){
for(int j=0;j<=k*2;j++){
if(i >= n + k - j - 1)
break;
ll x = arr[i] + arr[n + k - j - 1];
if(++frq[x] == k)
vec.push_back(x);
}
}
}
for(ll i : vec){
vector<int> ans;
int l = 0, r = n + k - 1;
while(l < r){
ll x = arr[l] + arr[r];
if(ans.size() == n)
break;
if(x == i){
ans.push_back(arr[l]);
ans.push_back(arr[r]);
}
if(x >= i)
r--;
if(x <= i)
l++;
}
if(ans.size() == n){
sort(all(ans));
for(int x : ans)
cout << x << ' ';
break;
}
}
return 0;
}
// https://www.youtube.com/watch?v=zL32whN6p0A&ab_channel=HeidiAdel-CartoonWorld
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... |