Submission #366035

# Submission time Handle Problem Language Result Execution time Memory
366035 2021-02-12T19:28:21 Z soba Table Tennis (info1cup20_tabletennis) C++14
0 / 100
248 ms 30212 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n , k;
    cin >> n >> k ;
    ll teams=n/2;
    vector<ll>v;
    ll x , y ;
    n+=k;
    map<ll,ll>mp , occ;
    
    for(int i = 0 ; i < n ; i++)
    {
        cin >>  x;
        mp[x]++;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    vector<ll>poten;
    set<ll>ss;
    for(int i = 0 ; i< 2*k ; i++)
    {
        for( int j = n-1; j >= n-(2*k) ; j-- )
        {
           ss.insert(v[i]+v[j]);
            occ[v[i]+v[j]]++;
        }
    }
    ll ansss;
    ll tmp=teams;
    for(ll u : ss)
    {
        if(occ[u]==k)
            {
                ansss=u;
                break;
            }
    }
    vector<ll>ansa;
    ll cnt;
        for(int j = 0 ; v[j]<n ; j++ )
        {
            if(mp[ansss-v[j]])
            {
                teams--;
                ansa.push_back(ansss-v[j]);
                ansa.push_back(v[j]);
            }
            if(teams==0)
                break;
        }
//    cout << ansa[0] << "\n";
//    cout << ansa.size() << "\n";
    sort( ansa.begin() , ansa.end());
    for(int i = 0 ; i < tmp*2 ; i++)
    {
        cout << ansa[i] <<  " " ;
    }
    return 0;
}

Compilation message

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:14:12: warning: unused variable 'y' [-Wunused-variable]
   14 |     ll x , y ;
      |            ^
tabletennis.cpp:46:8: warning: unused variable 'cnt' [-Wunused-variable]
   46 |     ll cnt;
      |        ^~~
tabletennis.cpp:49:24: warning: 'ansss' may be used uninitialized in this function [-Wmaybe-uninitialized]
   49 |             if(mp[ansss-v[j]])
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 748 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 3440 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 72 ms 21980 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 3072 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 620 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 620 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 248 ms 30212 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -