Submission #365939

# Submission time Handle Problem Language Result Execution time Memory
365939 2021-02-12T14:47:52 Z Belal Table Tennis (info1cup20_tabletennis) C++17
0 / 100
82 ms 2092 KB
#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){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;j>i+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;
}

Compilation message

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 time Memory Grader output
1 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 364 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 73 ms 2092 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 368 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 82 ms 364 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -