Submission #753093

# Submission time Handle Problem Language Result Execution time Memory
753093 2023-06-04T14:43:00 Z DJeniUp Table Tennis (info1cup20_tabletennis) C++17
0 / 100
139 ms 1448 KB
#include "bits/stdc++.h"
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("O3")

using namespace std;

typedef int ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pairll;
typedef pair<ll,ull>pairull;
typedef pair<ll,pairll>pair3l;
typedef long double ld;
typedef pair<ld,ll>pairld;

#define fr first
#define sc second
#define pb push_back
#define endl '\n'
#define N 100007
//#define MOD 998244353
#define INF 100000000000007
#define eps 0.0000000001

ll n,k,d[2*N],s[2*N];

ll S(ll x){
    ll res=0;
    for(int i=1;i<=n+k;i++){
        s[i]=0;
    }
    ll l=1;
    ll r=n+k;
    while(l<r){
        if(d[l]+d[r]<x)l++;
        else if(d[l]+d[r]>x)r--;
        else{
            res+=2;
            s[l]=1;
            s[r]=1;
            l++;
            r--;
        }
        if(res==n)return 1;
    }
    return 0;
}

int main(){
    
    cin>>n>>k;
    for(int i=1;i<=n+k;i++){
        cin>>d[i];
    }
    sort(d+1,d+1+n+k);
    ll fl=0;
    for(int i=1;i<=n+k;i++){
        for(int j=n+k;j>i;j--){
            if(j-i+1>n){
                if(S(d[i]+d[j])==1){
                    fl=1;
                    break;
                }
            }else break;
        }
        if(fl==1)break;
    }
    if(fl==0)exit(1);
    ll r=n;
    for(int i=1;i<=n+k;i++){
        if(s[i]==1){
            cout<<d[i];
            r--;
            if(r!=0)cout<<" ";
        }
        
    }
    //if(r!=0)exit(1);
    //cout<<endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 212 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 596 KB Output is correct
2 Runtime error 58 ms 1356 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 57 ms 1448 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 212 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 212 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 139 ms 212 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -