Submission #366027

# Submission time Handle Problem Language Result Execution time Memory
366027 2021-02-12T18:42:10 Z soba Table Tennis (info1cup20_tabletennis) C++14
0 / 100
3000 ms 178024 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int main()
{
    ll n , k;
    cin >> n >> k ;
    ll teams=n/2;
    vector<ll>v;
    ll x , y ;
    n+=k;
    map<ll,int>mp;
    for(int i = 0 ; i < n ; i++)
    {
        cin >>  x;
        mp[x]++;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    vector<ll>poten;
    for(int i = 0 ; i< k+1 ; i++)
    {
        for( int j = n-1; j >= n-(k+1) ; j-- )
        {
            poten.push_back(v[i]+v[j]);
        }
    }

    int sz=poten.size();
    vector<ll>ansa;
    for( int i = 0 ; i  < sz ; i++)
    {
        int tmam=1;
        ansa.clear();
        ll tmp=teams;
        for(int j = 0 ; j < n ; j++ )
        {
            if(poten[i]-v[j]==v[j])continue;
            if(mp[poten[i]-v[j]])
            {
                tmp--;
                ansa.push_back(poten[i]-v[j]);
                ansa.push_back(v[j]);
                tmam=0;
            }
            if(tmp==0)
                break;
        }
        if(tmp)
        {
            tmam=false;
        }
        if(tmam)
        {
            break;
        }
    }
    sort(ansa.begin(), ansa.end());
    for(int i = 0 ; i < teams*2 ; i++)
    {
        cout << ansa[i] <<  " " ;
    }
    return 0;
}

Compilation message

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:11:12: warning: unused variable 'y' [-Wunused-variable]
   11 |     ll x , y ;
      |            ^
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 876 KB Output not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 2152 KB Output is correct
2 Incorrect 256 ms 41692 KB Output not sorted
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 393 ms 67860 KB Output is correct
2 Incorrect 480 ms 88668 KB Output not sorted
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 940 ms 62956 KB Output not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 876 KB Output not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 876 KB Output not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3057 ms 178024 KB Time limit exceeded
2 Halted 0 ms 0 KB -