# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1118566 | ElayV13 | Table Tennis (info1cup20_tabletennis) | C++17 | 3090 ms | 511712 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld double
const int INF = 1e18;
const int mod = 12345;
const int sz = 1e6 + 5;
int n , k;
void solve()
{
cin >> n >> k;
vector < int > a(n + k);
for(int i = 0;i < n + k;i++)
{
cin >> a[i];
}
sort(a.begin() , a.end());
vector < int > q1;
vector < int > q2;
for(int i = 1;i < n + k;i++) q1.push_back(a[i]);
for(int i = 0;i < n + k - 1;i++) q2.push_back(a[i]);
set < int > s1;
for(int i = 0;i < q1.size() / 2;i++)
{
s1.insert(q1[i] + q1[q1.size() - i - 1]);
}
if(s1.size() == 1)
{
for(int i : q1) cout << i << ' ';
return;
}
s1.clear();
for(int i = 0;i < q2.size() / 2;i++)
{
s1.insert(q2[i] + q2[q2.size() - i - 1]);
}
if(s1.size() == 1)
{
for(int i : q2) cout << i << ' ';
return;
}
int ls = a[0] + a[n + k - 1];
map < int , int > cnt;
for(int i = 0;i < n + k;i++) cnt[a[i]]++;
int in = -1;
for(int i = 0;i < n + k;i++)
{
if(!cnt[ls - a[i]])
{
in = i;
break;
}
}
vector < int > l;
for(int i = 0;i < n + k;i++)
{
if(i == in) continue;
l.push_back(a[i]);
}
for(int i : l){
cout << i << ' ';
}
cout << endl;
}
signed main()
{
ios_base::sync_with_stdio(0);cin.tie(0);
if(k == 1)
{
solve();
return 0;
}
cin >> n >> k;
vector < int > a(n + k);
map < int , int > cnt;
for(int i = 0;i < n + k;i++)
{
cin >> a[i];
cnt[a[i]]++;
}
sort(a.begin() , a.end());
int ls = (n / 2);
map < int , int > m;
int pos = -1;
for(int i = 0;i < n + k - 1;i++)
{
bool f = 0;
for(int j = i + 1;j < n + k;j++)
{
if(a[j] == a[j - 1]) continue;
m[a[i] + a[j]]++;
if(m[a[i] + a[j]] == ls)
{
f = 1;
pos = a[i] + a[j];
break;
}
}
if(f) break;
}
vector < pair < int , int > > ans;
for(int i = 0;i < n;i++)
{
if(ans.size() == n / 2) break;
if(cnt[pos - a[i]] > 0) ans.push_back({a[i] , pos - a[i]});
}
vector < int > anss;
for(int i = 0;i < ans.size();i++)
{
anss.push_back(ans[i].first);
anss.push_back(ans[i].second);
}
sort(anss.begin() , anss.end());
for(int i : anss) cout << i << ' ';
//cout << pos << endl;
}
컴파일 시 표준 에러 (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... |