Submission #518300

# Submission time Handle Problem Language Result Execution time Memory
518300 2022-01-23T10:49:29 Z Ronin13 Table Tennis (info1cup20_tabletennis) C++14
24 / 100
3000 ms 720020 KB
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pb push_back
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define epb emplace_back
#define inf 1e9+1
#define linf 1e18+11
using namespace std;

map<int,pii>used;
int dp[1001][200001];
int main(){
    int n;cin>>n;
    int k;cin>>k;
    int a[n+k+1];
    for(int i=1;i<=n+k;i++){
        cin>>a[i];
    }
    for(int i=0;i<=min(n+k,2*(k+1));i++){
        for(int j=0;j<=n+k;j++)dp[i][j]=-inf;
    }
    dp[0][0]=0;
    sort(a+1,a+1+n+k);
    for(int i=min(2*k+2,k+n);i>=1;i--){
        for(int j=i+1;j<=n+k;j++){
            int x=a[i]+a[j];
            dp[i][j]=dp[used[x].f][used[x].s]+2;
        }
        for(int j=i+1;j<=n+k;j++){
            int x=a[i]+a[j];
            used[x]={i,j};
        }
    }
    int val=0;
    for(int i=1;i<=min(2*k+2,n+k);i++){
        for(int j=1;j<=n+k;j++){
           // cout<<dp[i][j]<<' ';
            if(dp[i][j]>=n){
                val=a[i]+a[j];
                break;
            }
        }
        if(val)break;
        //cout<<"\n";
    }
    int l=1,r=n+k;
    vector<int>vec;
    while(l<r){
        if(vec.size()==n)break;
        int ss=a[l]+a[r];
        if(ss==val){
            vec.pb(a[l]);
            vec.pb(a[r]);
            l++;
            r--;
            continue;
        }
        if(ss>val){
            r--;
            continue;
        }
        l++;
    }
    sort(vec.begin(),vec.end());
    for(int to:vec)cout<<to<<' ';
}

Compilation message

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:53:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   53 |         if(vec.size()==n)break;
      |            ~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 716 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 2160 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 387 ms 50244 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1612 KB Output is correct
2 Correct 5 ms 2380 KB Output is correct
3 Correct 8 ms 2508 KB Output is correct
4 Correct 6 ms 2508 KB Output is correct
5 Correct 7 ms 2508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Incorrect 18 ms 2688 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 424 KB Output is correct
2 Execution timed out 3060 ms 288732 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 44 ms 9124 KB Output is correct
2 Execution timed out 3113 ms 720020 KB Time limit exceeded
3 Halted 0 ms 0 KB -