# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
762392 | voliaanyk | Table Tennis (info1cup20_tabletennis) | C++14 | 15 ms | 1492 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;
map<ll, ll> m;
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;i++){
for(int j=n;j>=n-k+1;j--){
if(i<j) m[a[j]+a[i]]++;
}
}
for(auto r:m){
if(r.se < k) continue;
if(check(r.fi)){
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... |