이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define Baytoro_MayrambekovOrz void solve()
#define ios ios::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr first
#define sc second
#define int long long
int n,k;
vector<int> vec,ans;
bool check(int x){
int i;
int cnt=0;
ans.clear();
int r=n+k-1;
for(i=0;i<r && cnt<n/2;i++){
while(r>i && vec[i]+vec[r]>x)
r--;
if(r>i && vec[i]+vec[r]==x){
cnt++;
ans.pb(vec[i]);
ans.pb(vec[r]);
}
}
return n/2==cnt;
}
int a,b,c,m,j,x,y,cnt=0,sum=0,res=0;
Baytoro_MayrambekovOrz{
int i;
cin>>n>>k;
vec.resize(n+k);
for(i=0;i<n+k;i++){
cin>>vec[i];
}
for(i=0;i<=min(k*2,n+k);i++){
for(j=max(0ll,n-k);j<n+k;j++){
if(check(vec[i]+vec[j])){
sort(all(ans));
for(auto it: ans)
cout<<it<<' ';
return;
}
}
}
}
main(){
ios;
int T=1;
//cin>>T;
while(T--){
solve();
}
}
컴파일 시 표준 에러 (stderr) 메시지
tabletennis.cpp:50:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
50 | main(){
| ^~~~
# | 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... |