# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
762351 | voliaanyk | Table Tennis (info1cup20_tabletennis) | C++14 | 3069 ms | 6552 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 DIM 160007
#define DIM2 2007
#define fi first
#define se second
#define mod 1000000007
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
ll n, k, a[DIM];
vector<ll> res;
set<ll> s;
bool check(ll d){
ll l = 1, r = n+k;
res.clear();
while(l<r){
if(a[r]+a[l] == d){
res.push_back(a[l]); res.push_back(a[r]);
r--;
l++;
}
else if(a[r] + a[l] > d) r--;
else l++;
if(res.size()>=n) return true;
}
return false;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>k;
for(int i=1;i<=n+k;i++){
cin>>a[i];
}
for(int i=1;i<=k+1;i++){
for(int j=n+k;j>=n+i-1;j--){
if(i<j) s.insert(a[j]+a[i]);
}
}
for(auto r:s){
if(check(r)){
sort(res.begin(), res.end());
for(int i=0;i<res.size();i++){
cout<<res[i]<<" ";
}
cout<<endl;
return 0;
}
}
return 0;
}
/*
4 3
1 2 3 4 8 10 20
4 2
1 2 3 4 5 6
*/
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... |