이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define all(a) a.begin(),a.end()
const int N=1e5;
const int off=(1<<20);
const int MOD = 1e9+7;
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n,k;
cin >> n >> k;
int sz=n+k;
int a[sz];
map<int,int>mp;
for(int i=0;i<sz;i++){
cin >>a[i];
mp[a[i]]++;
}
sort(a,a+sz);
if(k==1){
int f=a[sz/2]+a[sz/2-1],s=a[sz/2]+a[sz/2+1],t=a[0]+a[sz-1];
int x=0,y=0,z=0;
// cout<<f<<' '<<s << ' '<<t<<endl;
for(int i=0;i<sz;i++){
if(a[i]!=f-a[i]){
if(!mp[f-a[i]]){
if(x)x=-1;
else x=a[i];
}
}
else{
x=a[i];
}
if(a[i]!=s-a[i]){
if(!mp[s-a[i]]){
if(y)z=-1;
else y=a[i];
}
}
else{
y=a[i];
}
if(a[i]!=t-a[i]){
if(!mp[t-a[i]]){
if(z)z=-1;
else z=a[i];
}
}
else{
z=a[i];
}
}
int ans=max({z,x,y});
for(int i=0;i<sz;i++){
if(a[i]!=ans)cout<<a[i]<<' ';
}
}
else if(k==2){
vector<int>v;
v.pb(a[sz/2]+a[sz/2+1]);
v.pb(a[sz/2]+a[sz/2+2]);
v.pb(a[sz/2-1]+a[sz/2]);
v.pb(a[sz/2+1]+a[sz/2+2]);
v.pb(a[sz/2-1]+a[sz/2+1]);
v.pb(a[sz/2-1]+a[sz/2+2]);
v.pb(a[0]+a[sz-1]);
int h[7]={0};
pair<int,int>pp[7];
for(int i=0;i<7;i++)pp[i]={0,0};
for(int i=0;i<sz;i++){
for(int j=0;j<7;j++){
if(a[i]!=v[j]-a[i]){
if(!mp[v[j]-a[i]]){
if(pp[j].F==0)pp[j].F=a[i];
else if(pp[j].S==0)pp[j].S=a[i];
else pp[j]={-1,-1};
}
}
else{
if(pp[j].F==0)pp[j].F=a[i];
else if(pp[j].S==0)pp[j].S=a[i];
else pp[j]={-1,-1};
}
}
}
pair<int,int>p;
for(int i=0;i<7;i++){
if(pp[i].F!=-1)p=pp[i];
}
for(int i=0;i<sz;i++){
if(p.F!=a[i]&&p.S!=a[i])cout<<a[i]<<' ';
}
}
}
/*
*/
컴파일 시 표준 에러 (stderr) 메시지
tabletennis.cpp: In function 'int main()':
tabletennis.cpp:76:11: warning: unused variable 'h' [-Wunused-variable]
76 | int h[7]={0};
| ^
# | 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... |