이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define PB push_back
int n,k;
vi a,ans;
bool solve(int x){
int l=0,r=n+k-1;ans.clear();
while(l<r&&ans.size()<n){
while(l<r&&a[l]+a[r]>x)r--;
if(l<r&&a[l]+a[r]==x){
ans.PB(a[l]);ans.PB(a[r]);
}
if(r-l+1+ans.size()<n)break;
l++;
}
sort(ans.begin(),ans.end());
return ans.size()==n;
}
int main() {
cin>>n>>k;a.resize(n+k);
REP(i,0,n+k)cin>>a[i];
REP(i,0,k+1)REP(j,n-1,n+k)if(solve(a[i]+a[j])){
for(auto u:ans)cout<<u<<" ";
return 0;
}
}
컴파일 시 표준 에러 (stderr) 메시지
tabletennis.cpp: In function 'bool solve(int)':
tabletennis.cpp:10:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
10 | while(l<r&&ans.size()<n){
| ~~~~~~~~~~^~
tabletennis.cpp:15:28: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
15 | if(r-l+1+ans.size()<n)break;
| ~~~~~~~~~~~~~~~~^~
tabletennis.cpp:19:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
19 | return ans.size()==n;
| ~~~~~~~~~~^~~
# | 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... |