제출 #365955

#제출 시각아이디문제언어결과실행 시간메모리
365955BelalTable Tennis (info1cup20_tabletennis)C++14
100 / 100
258 ms8044 KiB
#include <bits/stdc++.h> using namespace std; int arr[150405],arr2[150005],n,k; bool fun(int idx,int x,int y,int sum){ if(idx==n/2 && arr[x]+arr[y]==sum){ arr2[idx-1]=arr[x]; arr2[n-idx]=arr[y]; return true; } if((x-idx+1+n-1-y-idx+1==k&&arr[x]+arr[y]!=sum)||y-1==x ||y==x){return false;} if(arr[x]+arr[y]==sum){ if(fun(idx+1,x+1,y-1,sum)){ arr2[idx-1]=arr[x]; arr2[n-idx]=arr[y]; return true; } else{return false;} } if(arr[x]+arr[y]>sum){return fun(idx,x,y-1,sum);} if(arr[x]+arr[y]<sum){return fun(idx,x+1,y,sum);} } int main() { cin>>n>>k; for(int i=0;i<n+k;i++){ cin>>arr[i]; } for(int i=0;i<=k;i++){ for(int j=n+k-1;j>=i-1+n;j--){ if(fun(1,i,j,arr[i]+arr[j])){ cout<<arr2[0]; for(int g=1;g<n;g++){ cout<<" "<<arr2[g]; } return 0; } } } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

tabletennis.cpp: In function 'bool fun(int, int, int, int)':
tabletennis.cpp:24:1: warning: control reaches end of non-void function [-Wreturn-type]
   24 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...