# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
685672 | heeheeheehaaw | Table Tennis (info1cup20_tabletennis) | C++17 | 101 ms | 8012 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 <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int n, k;
int v[200005];
void afisare(vector<int> rez)
{
sort(rez.begin(), rez.end());
cout<<v[rez[0]];
for(int i = 1; i < rez.size(); i++)
cout<<" "<<v[rez[i]];
return;
}
vector<int> possible(int sum)
{
vector<int> rez;
int dr = n + k;
for(int i = 1; i <= n; i++)
{
while(v[i] + v[dr] > sum)
dr--;
if(i >= dr)
break;
if(v[i] + v[dr] < sum)
{
rez.clear();
return rez;
}
rez.push_back(i);
rez.push_back(dr);
dr--;
}
if((int)rez.size() == n)
return rez;
rez.clear();
return rez;
}
void solve1()
{
for(int i = 1; i <= n + k; i++)
for(int j = i + 1; j <= n + k; j++)
{
vector<int> rez = possible(v[i] + v[j]);
if(rez.size() != 0)
{
afisare(rez);
return;
}
}
return;
}
void solve2()
{
map<int, int> mp;
for(int i = 1; i <= k; i++)
for(int j = n; j <= n + k; j++)
mp[v[i] + v[j]]++;
for(auto it: mp)
{
if(it.second >= k)
{
vector<int> rez = possible(it.first);
if(rez.size() != 0)
{
afisare(rez);
return;
}
}
}
return;
}
int main()
{
cin>>n>>k;
for(int i = 1; i <= n + k; i++)
cin>>v[i];
if(n + k <= 4 * k)
solve1();
else
solve2();
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... |